OlliP
OlliP

Reputation: 1585

How to increase heap space in Google Go

I'm running the Go code from Rober Hundt's benchmark to compare performance of Go with the other languages. When I run the Go code from that benchmark (see http://code.google.com/p/multi-language-bench/source/browse/trunk/src/#src%2Fhavlak%2Fgo) I get an out of memory exception:

................runtime: out of memory: cannot allocate 1048576-byte block (1270808576 in use) throw: out of memory

My question is how I can increase Go's memory space. Is there some start-up parameter or some flag for the compiler that can be set accordingly? The Makefile file of the Go source doesn't reveal anything...

Thanks, Oliver

Upvotes: 3

Views: 1593

Answers (4)

OlliP
OlliP

Reputation: 1585

For those that might be interested I sent a mail to mr. hundt himself asking whether there is some (undocumented) compiler switch with which the heap size could be adapted or parameterized somehow. This was because I first mistakenly assumed that such a switch must exist, but is not documented. And nobody hat replied to my post here seemed to know, either. I guess I was "too much inspired" here by how the jvm works ...

Anyway, he recommended to try different compilers (gcc based compiler, or the plan-9 based compiler) as one might work better than the other. Then try on a 64-bit machine, of course.

He also pointed my to some good article about Go's memory management: http://lwn.net/Articles/428100/

But no, there is no compiler switch to play around with memory settings.

Regards, Oliver

Upvotes: 0

voidlogic
voidlogic

Reputation: 6826

If you share your OS version, if it is 32 vs 64 bits and your go version result, we can probably help you more.

  • The 32-bit version of Go has known heap memory issues and is generally not used in production. Make sure you are using the 64-bit version of Go on a 64-bit platform.
  • Go tip, the branch of go that will become Go 1.1 has upgraded the maximum heap space from 8 GB to 128 GB. The core Go developers I have spoken with recommend using Go tip for memory intensive production uses.
  • Go on Windows is less used and thus less tested, this could be a bug. Go is much more tried and true on Linux ans to a lesser extent OS X.
  • As peterSO mentioned, Robert Hundt's benchmark is flawed- read more here: Profiling Go Programs

Upvotes: 6

peterSO
peterSO

Reputation: 166569

Robert Hundt's benchmark is flawed. It's not a valid benchmark for Go. Read Profiling Go Programs for details.

Upvotes: 1

zzzz
zzzz

Reputation: 91243

One can only wildly guess - for the lack of more details.

  • If you're running a 32 bit Go version, try the 64 bit one instead and use the tip revision.
  • If possible, use a *nix platform - it has IMO better memory management.

Upvotes: 4

Related Questions