title: How to allocate 16GB of memory in Go?
body: <p>I'm using the following simple Go code to allocate a 3D array of size 1024x1024x1024:</p>
  
  <pre><code>grid = make([][][]TColor, 1024)
  for x = 0; x &lt; 1024; x++ {
      grid[x] = make([][]TColor, 1024)
      for y = 0; y &lt; 1024; y++ {
          grid[x][y] = make([]TColor, 1024)
      }
  }
  </code></pre>
  
  <p>That TColor struct is a 4-component float64 vector:</p>
  
  <pre><code>type TColor struct { R, G, B, A float64 }
  </code></pre>
  
  <p>Halfway (x=477 and y=~600ish) through the allocation, the inner-most make() call panics with... <strong>runtime: out of memory: cannot allocate 65536-byte block (17179869184 in use)</strong></p>
  
  <p>This works fine with lower grid resolutions, ie 256³, 128³ etc. Now since the size of the struct is 4x4 bytes, that whole grid should require exactly 16 GB of memory. My machine (openSuse 12.1 64bit) has 32 GB of addressable physical (ie not-virtual) memory. Why can Go (weekly.2012-02-22) not allocate even half of this?</p>