title: Golang and large memory chunk allocation
body: <p>I have the rather stupid benchmark to test the efficiency of memory allocation:</p>
  
  <pre><code>package main
  
  import (
      "time"
      "fmt"
  )
  
  func main() {
  
      size := 1024 * 1024 * 1024
  
      t := time.Now()
      for j := 0; j &lt; 100; j += 1 {
          a := make([]int, size)
          for i := 0; i &lt; size; i += 1 {
              a[i] = i
          }
          a = nil
      }
      t1 := time.Now()
      fmt.Printf("Duration: %1d", t1.Sub(t).Seconds())
  }
  </code></pre>
  
  <p>It takes roughly 2-3 minutes on Mac Pro with 16GB of RAM, the memory usage is consistent at 5-8 GB for the process.</p>
  
  <p>The very similar code in Java takes 3 GB of memory and completes in 30 seconds.</p>
  
  <p>What am I missing here?</p>