Hi, I have a gc.go: package main
import ( "fmt" "runtime/debug" ) const N = 3e8 func f(x int) { ls := make([]uint64, N) for i := N - 1; i >= 0; i-- { ls[i] = uint64(i) } fmt.Println(ls[x]) } func main() { debug.SetGCPercent(10) f(8) f(9) } 1st call suscessfully returns, I have enough ram on my laptop, but the 2nd call fails with "fatal error: runtime: out of memory" The output is in gc.txt. So what's happening ? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
8 fatal error: runtime: out of memory runtime stack: runtime.throw(0x4a726c, 0x16) /Program/go/src/runtime/panic.go:596 +0x95 runtime.sysMap(0xc4af1e0000, 0x8f0e0000, 0x0, 0x515a98) /Program/go/src/runtime/mem_linux.go:216 +0x1d0 runtime.(*mheap).sysAlloc(0x4fd9c0, 0x8f0e0000, 0x27) /Program/go/src/runtime/malloc.go:428 +0x374 runtime.(*mheap).grow(0x4fd9c0, 0x47869, 0x0) /Program/go/src/runtime/mheap.go:774 +0x62 runtime.(*mheap).allocSpanLocked(0x4fd9c0, 0x47869, 0x1) /Program/go/src/runtime/mheap.go:678 +0x44f runtime.(*mheap).alloc_m(0x4fd9c0, 0x47869, 0x100000000, 0xffffffffffffffff) /Program/go/src/runtime/mheap.go:562 +0xe2 runtime.(*mheap).alloc.func1() /Program/go/src/runtime/mheap.go:627 +0x4b runtime.systemstack(0x7ffc67c18f20) /Program/go/src/runtime/asm_amd64.s:343 +0xab runtime.(*mheap).alloc(0x4fd9c0, 0x47869, 0x10100000000, 0x42e8c1) /Program/go/src/runtime/mheap.go:628 +0xa0 runtime.largeAlloc(0x8f0d1800, 0xc42001c001, 0xc4200001a0) /Program/go/src/runtime/malloc.go:795 +0x93 runtime.mallocgc.func1() /Program/go/src/runtime/malloc.go:690 +0x3e runtime.systemstack(0x4fab00) /Program/go/src/runtime/asm_amd64.s:327 +0x79 runtime.mstart() /Program/go/src/runtime/proc.go:1132 goroutine 1 [running]: runtime.systemstack_switch() /Program/go/src/runtime/asm_amd64.s:281 fp=0xc420028628 sp=0xc420028620 runtime.mallocgc(0x8f0d1800, 0x489da0, 0xc420028701, 0x1) /Program/go/src/runtime/malloc.go:691 +0x930 fp=0xc4200286c8 sp=0xc420028628 runtime.makeslice(0x489da0, 0x11e1a300, 0x11e1a300, 0x2, 0x0, 0x0) /Program/go/src/runtime/slice.go:54 +0x7b fp=0xc420028718 sp=0xc4200286c8 main.f(0x9) /Dev/go/src/tools/gc.go:11 +0x43 fp=0xc420028768 sp=0xc420028718 main.main() /Dev/go/src/tools/gc.go:21 +0x44 fp=0xc420028788 sp=0xc420028768 runtime.main() /Program/go/src/runtime/proc.go:185 +0x20a fp=0xc4200287e0 sp=0xc420028788 runtime.goexit() /Program/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc4200287e8 sp=0xc4200287e0 exit status 2