Question

I run go build in the $GOPATH of my arch Vagrant box.
But it prints out

 runtime: panic before malloc heap initialized
 fatal error: runtime: cannot allocate heap metadata

And the box is 3.10.9-1-ARCH x86_64, memory 242M.

Why I can't build go files in the box?

Thanks in advance.

Was it helpful?

Solution

Looks like this is caused by not enough virtual memory

$ ulimit -v 242000
$ go build prog.go
runtime: panic before malloc heap initialized
fatal error: runtime: cannot allocate heap metadata

64bit go needs lots of virtual memory space but not necessarily that much real memory.

You could fix this by allocating more memory to the container.

You could also play with the setting of /proc/sys/vm/overcommit_memory.

You could also try allocating swap to the container (if possible).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top