Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
391 views
in Technique[技术] by (71.8m points)

java - 错误java.lang.OutOfMemoryError:超出了GC开销限制(Error java.lang.OutOfMemoryError: GC overhead limit exceeded)

I get this error message as I execute my JUnit tests:

(我执行JUnit测试时收到以下错误消息:)

java.lang.OutOfMemoryError: GC overhead limit exceeded

I know what an OutOfMemoryError is, but what does GC overhead limit mean?

(我知道什么是OutOfMemoryError ,但是GC开销限制是什么意思?)

How can I solve this?

(我该如何解决?)

  ask by Mnementh translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This message means that for some reason the garbage collector is taking an excessive amount of time (by default 98% of all CPU time of the process) and recovers very little memory in each run (by default 2% of the heap).

(该消息表示由于某种原因,垃圾收集器占用了过多的时间(默认情况下为该进程所有CPU时间的98%),并且每次运行时恢复的内存很少(默认为堆的2%)。)

This effectively means that your program stops doing any progress and is busy running only the garbage collection at all time.

(这实际上意味着您的程序停止任何进展,并且一直在忙于仅运行垃圾回收。)

To prevent your application from soaking up CPU time without getting anything done, the JVM throws this Error so that you have a chance of diagnosing the problem.

(为了防止您的应用程序浪费CPU时间而不做任何事情,JVM抛出此Error以便您有机会诊断问题。)

The rare cases where I've seen this happen is where some code was creating tons of temporary objects and tons of weakly-referenced objects in an already very memory-constrained environment.

(我见过这种情况的罕见情况是,某些代码在一个已经非常受内存限制的环境中创建了大量的临时对象和大量的弱引用对象。)

Check out this article for details (specifically this part ).

(请查看本文以了解详细信息(特别是本部分 )。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...