如何在Google Go中增加堆空间

huangapple go评论86阅读模式
英文:

How to increase heap space in Google Go

问题

我正在运行Rober Hundt的基准测试中的Go代码,以比较Go与其他语言的性能。当我运行该基准测试中的Go代码时(请参见http://code.google.com/p/multi-language-bench/source/browse/trunk/src/#src%2Fhavlak%2Fgo),我遇到了内存不足的异常:

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

我的问题是如何增加Go的内存空间。是否有一些启动参数或编译器的标志可以相应地设置?Go源代码的Makefile文件没有透露任何信息...

谢谢,Oliver

英文:

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

答案1

得分: 6

如果您分享您的操作系统版本,如果它是32位还是64位,并且您的go version结果,我们可能可以更好地帮助您。

  • Go的32位版本已知存在堆内存问题,通常不用于生产环境。请确保您在64位平台上使用64位版本的Go。

  • Go的tip版本,即将成为Go 1.1的分支,已将最大堆空间从8GB升级到128GB。我与核心Go开发人员交流过,他们建议在内存密集型生产环境中使用Go tip。

  • 在Windows上使用Go的人较少,因此测试也较少,这可能是一个bug。在Linux上,Go经过了更多的尝试和验证,OS X上也有一定程度的尝试和验证。

  • 正如peterSO提到的,Robert Hundt的基准测试存在缺陷-在这里阅读更多信息:Profiling Go Programs

英文:

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

答案2

得分: 4

  • 如果您正在运行32位的Go版本,请尝试使用64位版本,并使用最新的修订版本。
  • 如果可能的话,请使用*nix平台,它在我看来具有更好的内存管理能力。
英文:

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.

答案3

得分: 1

Robert Hundt的基准测试有缺陷。它不是Go的有效基准测试。详细信息请阅读Profiling Go Programs

英文:

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

答案4

得分: 0

对于那些可能感兴趣的人,我给亨特先生发了一封邮件,询问是否有一些(未记录的)编译器开关可以调整或参数化堆大小。这是因为我最初错误地认为这样的开关必须存在,但没有记录。而且似乎没有人回复我在这里的帖子,也不知道。我想我在这里受到了JVM工作方式的“太多启发”...

无论如何,他建议尝试不同的编译器(基于gcc的编译器或基于plan-9的编译器),因为其中一个可能比另一个更好。当然,要在64位机器上尝试。

他还指向了一篇关于Go内存管理的好文章:http://lwn.net/Articles/428100/

但是,没有编译器开关可以调整内存设置。

问候,奥利弗

英文:

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

huangapple
  • 本文由 发表于 2013年1月28日 17:57:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/14559487.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定