简体   繁体   English

gc堆分配和我的java程序之间的速率

[英]rate beetween gc heap allocation and my java program

My application throws java.lang.OutOfMemoryError: GC overhead limit exceeded error. 我的应用程序抛出java.lang.OutOfMemoryError: GC overhead limit exceeded错误。 I searched it and get enough information. 我进行了搜索,并获得了足够的信息。 Oracle says : 甲骨文说:

Cause: The detail message "GC overhead limit exceeded" indicates that the garbage collector is running all the time and Java program is making very slow progress. 原因:详细消息“超出了GC开销限制”表明垃圾收集器一直在运行,并且Java程序的进度非常缓慢。 After a garbage collection, if the Java process is spending more than approximately 98% of its time doing garbage collection and if it is recovering less than 2% of the heap and has been doing so far the last 5 (compile time constant) consecutive garbage collections, then a java.lang.OutOfMemoryError is thrown. 进行垃圾回收之后,如果Java进程花费了其大约98%的时间用于垃圾回收,并且正在恢复的内存少于2%,并且到目前为止已经执行了最后5个(编译时间常数)连续垃圾集合,则引发java.lang.OutOfMemoryError。 This exception is typically thrown because the amount of live data barely fits into the Java heap having little free space for new allocations. 通常会抛出此异常,因为活动数据量几乎无法容纳到Java堆中,而新分配的可用空间却很少。 Action: Increase the heap size. 行动:增加堆大小。 The java.lang.OutOfMemoryError exception for GC Overhead limit exceeded can be turned off with the command line flag -XX:-UseGCOverheadLimit. 可以通过命令行标志-XX:-UseGCOverheadLimit关闭超出GC开销限制的java.lang.OutOfMemoryError异常。

My question is; 我的问题是; how can I track heap allocated by GC , and by my java program. 如何跟踪GC和Java程序分配的堆。 I tried jstat -gcutil but it is not have enough information. 我尝试了jstat -gcutil但是它没有足够的信息。 Is there a tool that I can see the rate between my java program heap allocation over GC heap allocation? 有没有一种工具可以查看Java程序堆分配与GC堆分配之间的比率? Thanks in advice. 感谢您的建议。

Note that it is not "java heap" vs "gc heap allocation", but CPU time dedicated to the actual program vs CPU time dedicated to GC. 请注意,它不是“ java堆”还是“ gc堆分配”,而是专用于实际程序的CPU时间与专用于GC的CPU时间。 The exception is thrown when most of the time is spent in the garbage collector. 当大部分时间都花在垃圾收集器上时,将引发异常。

This happens when the allocated heap is near to its maximum size (option -Xmx ) and most of the object in the heap are reachable . 当分配的堆接近其最大大小(选项-Xmx )并且堆中的大多数对象都可以访问时,就会发生这种情况。 It is your job to find whether the maximum size is too small (likely if you are using the default values), or there is a memory leak (an object that is preventing a large tree to be collected). 您的工作是查找最大大小是否太小(可能使用的是默认值),或者是否存在内存泄漏(阻止收集大树的对象)。

When dealing with this issues, I prefer using jvisualvm, which is provided with the Oracle JDK and gives realtime graphical information. 处理此问题时,我更喜欢使用jvisualvm,它是Oracle JDK随附的,并提供实时图形信息。

Latest JVM give more detailed information than earlier ones, but they also use different GC algorithms, which may change the observed results. 最新的JVM比早期的JVM提供更详细的信息,但是它们也使用不同的GC算法,这可能会改变观察到的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM