Go: time.sleep and memory usage
<p>When running the code below, the program starts at around 1.5M and then gradually grows until 6.4M. I'm wondering why. 
Removing <em>time.sleep</em> fixes the issue.</p>

<p>Is there a way to use the for-select pattern with a default and sleep some time in the default without any mem change?</p>

<p>Calling <em>runtime.GC()</em> after the sleep does fix the issue. Can we achieve the same thing without having to call the GC ?</p>

<pre><code>package main

import (
    "time"
)

func main() {
    c := make(chan struct{})
    for {
        select {
        case &lt;-c:
            //some work
        default:
            //some work
            time.Sleep(time.Millisecond * 1)
        }
    }
}
</code></pre>

<p>Same with :</p>

<pre><code>package main

import (
    "time"
)

func main() {
    c := make(chan struct{})
    for {
        select {
        case &lt;-c:
        case &lt;-time.After(time.Millisecond * 10):
        }
    }
}
</code></pre>

<hr>

<p>After some time researching, I achieved it with the following code. Still wonder why time.sleep increases mem usage?</p>

<pre><code>package main

import (
    "time"
)

func main() {
    c := make(chan bool)
    timer := time.NewTimer(0)
    for {
        select {
        case &lt;-c:
        default:
            timer.Reset(time.Millisecond * 1)
            &lt;-timer.C
        }
    }
}
</code></pre>