<p dir="auto">Consider the following program that I run with Go 1.5.2 on 64-bit Fedora Linux:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="package main
import &quot;fmt&quot;
func main() {
    a := make([]byte, 185 * 1024 * 1024)
    for i := 0; i &lt; len(a); i += 4096 {
        a[i] = 'x'
    }
    fmt.Printf(&quot;%c\n&quot;, a[0])
}"><pre class="notranslate"><code class="notranslate">package main
import "fmt"
func main() {
    a := make([]byte, 185 * 1024 * 1024)
    for i := 0; i &lt; len(a); i += 4096 {
        a[i] = 'x'
    }
    fmt.Printf("%c\n", a[0])
}
</code></pre></div>
<p dir="auto">It allocates 185MB byte array and then forces OS to commit memory to it via touching all the pages. This programs runs OK and prints expected <code class="notranslate">x</code> even if I restrict the size of available virtual memory per process to 200MB using ulimit:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="~/s&gt; ulimit -S -v 204800
~/s&gt; go run test.go
x"><pre class="notranslate"><code class="notranslate">~/s&gt; ulimit -S -v 204800
~/s&gt; go run test.go
x
</code></pre></div>
<p dir="auto">Now consider its modification like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="package main
import &quot;fmt&quot;
func main() {
    a := make([]byte, 85 * 1024 * 1024)
    a = nil
    a = make([]byte, 150 * 1024 * 1024)
    for i := 0; i &lt; len(a); i += 4096 {
        a[i] = 'x'
    }
    fmt.Printf(&quot;%c\n&quot;, a[0])
}"><pre class="notranslate"><code class="notranslate">package main
import "fmt"
func main() {
    a := make([]byte, 85 * 1024 * 1024)
    a = nil
    a = make([]byte, 150 * 1024 * 1024)
    for i := 0; i &lt; len(a); i += 4096 {
        a[i] = 'x'
    }
    fmt.Printf("%c\n", a[0])
}
</code></pre></div>
<p dir="auto">It allocates first 85MB, then clears the reference to the slice, and then allocates 150MB. This time under the same 200MB limit as set with ulimit it fails:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="~/s&gt; go run test.go
fatal error: runtime: out of memory"><pre class="notranslate"><code class="notranslate">~/s&gt; go run test.go
fatal error: runtime: out of memory
</code></pre></div>
<p dir="auto">The same failure happens even with the explicit GC call after a = nil:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="package main
import &quot;fmt&quot;
import &quot;runtime&quot;
func main() {
    a := make([]byte, 85 * 1024 * 1024)
    a = nil
    runtime.GC()
    a = make([]byte, 150 * 1024 * 1024)
    for i := 0; i &lt; len(a); i += 4096 {
        a[i] = 'x'
    }
    fmt.Printf(&quot;%c\n&quot;, a[0])
}"><pre class="notranslate"><code class="notranslate">package main
import "fmt"
import "runtime"
func main() {
    a := make([]byte, 85 * 1024 * 1024)
    a = nil
    runtime.GC()
    a = make([]byte, 150 * 1024 * 1024)
    for i := 0; i &lt; len(a); i += 4096 {
        a[i] = 'x'
    }
    fmt.Printf("%c\n", a[0])
}
</code></pre></div>
<p dir="auto">Is it just a runtime bug?  If not, how can I force the runtime to release a large allocation?</p>
<p dir="auto">by <strong>jan.newmarch</strong>:</p>
<pre class="notranslate">www.google.com is blocked in China. So the test net.TestDialGoogle fails, aborting all
the rest of the tests. Preferred if failure is reported but the tests continue

--- FAIL: net.TestDialGoogle
    -- 74.125.19.99:80 --
    -- www.google.com:80 --
    Dial("tcp4", "", "www.google.com:80") = _, dial tcp4 66.249.89.104:80: connection timed out

8g version 6288 release release.2010-09-15</pre>