在堆内存使用中PS旧的Gen内存:GC设置

时间:2021-11-10 17:17:31

在堆内存使用中PS旧的Gen内存:GC设置

Below are my JVM settings:

以下是我的JVM设置:

 JAVA_OPTS=-server -Xms2G -Xmx2G -XX:MaxPermSize=512M -Dsun.rmi.dgc.client.gcInterval=1200000 -Dsun.rmi.dgc.server.gcInterval=1200000 -XX:+UseParallelOldGC -XX:ParallelGCThreads=2 -XX:+UseCompressedOops  -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jbos88,server=y,suspend=n

Problem: Total Heap Memory: 2GB Old Gen: 1.4GB (2/3 of Heap) New Gen: 600MB(1/3 of Heap)

问题:总堆内存:2GB老Gen: 1.4GB(堆的2/3)新Gen: 600MB(堆的1/3)

The Old Gen grows in memory beyond 70% 0f its allocated size and never is subjected to GC even at 100% i.e 1.4GB. One can see the graph below it peaks and never is GC, the drop in memory is when it was forced to GC from the JConsole. This problem is eventually bringing the web server down.

旧的Gen在内存中增长超过其分配大小的70%,即使在100% i时也不会受到GC的影响。e 1.4 gb。可以看到下图的峰值,而不是GC,内存的下降是当它从JConsole*执行GC时。这个问题最终导致web服务器宕机。

Anything that i am missing or wrongly setting the JVM?

我是否遗漏了什么,或者错误地设置了JVM?

Thanks for the help in advance.

提前谢谢你的帮助。

Updating my Question:

更新我的问题:

After heap analysis it appears like Stateful session bean is the prime suspect: 在堆内存使用中PS旧的Gen内存:GC设置 We have stateful session beans that hold the persistence logic assisted by Hibernate.

在堆分析之后,似乎有状态会话bean是主要的怀疑对象:我们有有状态会话bean,它持有Hibernate辅助的持久性逻辑。

3 个解决方案

#1


5  

The GC will be called eventually, the old gen is almost never called(Because it is extremely slow). The Gc does run but it will only run on the new gen and survivor gen at first, it has a completely different algorithm for cleaning the old gen which is slower then new/survivor gens.

GC最终会被调用,旧的gen几乎不会被调用(因为它非常慢)。Gc会运行,但它只会运行新的gen和幸存者gen,它有一个完全不同的算法来清除旧的gen,它比新的/幸存者更慢。

Those numbers are really high, the oldgen should never reach sum a high number compared to the newgen. My guess is that you have a memory leak.

这些数字真的很高,与新一代相比,老人永远不应该达到一个很高的数字。我猜你有内存泄漏。

I can only guess you program is dealing with big files, you are probably saving to references to them for to long.

我只能猜测您的程序正在处理大文件,您可能将它们的引用保存了很长一段时间。

#2


3  

Even still having the main problem (memory leak) resolved, if you still want the old gen to be cleared in frequent small sized pauses, you may try setting

即使仍然解决了主要的问题(内存泄漏),如果仍然希望在频繁的小停顿中清除旧的gen,您可以尝试设置

-XX:MaxGCPauseMillis=(time in millis)

and this is only applicable with Parallel Collector and when Adaptive Sizing Policy is on. By default Adaptive Sizing Policy is on, but, if you want to explicitly mention this you can use.

这只适用于并行收集器和自适应规模策略。默认情况下,自适应调整大小策略是打开的,但是,如果您想明确地提到这一点,您可以使用它。

-XX:+UseAdaptiveSizePolicy

Or else you can switch to CMS collector where you can use

或者你可以切换到CMS收集器,在那里你可以使用。

-XX:CMSInitiatingOccupancyFraction=(% value) 
-XX:+UseCMSInitiatingOccupancyOnly

Which is a more reliable way of collecting the old gen when it has reached a certain fraction of the the old gen.

这是一种更可靠的方法来收集旧一代,当它到达旧一代的一定比例时。

#3


3  

在堆内存使用中PS旧的Gen内存:GC设置The stateful session beans were making the JVM run out of memory. Explicitly handling them using @Remove annotation resolved this issue.

有状态会话bean使JVM内存不足。使用@Remove注释显式地处理它们解决了这个问题。

#1


5  

The GC will be called eventually, the old gen is almost never called(Because it is extremely slow). The Gc does run but it will only run on the new gen and survivor gen at first, it has a completely different algorithm for cleaning the old gen which is slower then new/survivor gens.

GC最终会被调用,旧的gen几乎不会被调用(因为它非常慢)。Gc会运行,但它只会运行新的gen和幸存者gen,它有一个完全不同的算法来清除旧的gen,它比新的/幸存者更慢。

Those numbers are really high, the oldgen should never reach sum a high number compared to the newgen. My guess is that you have a memory leak.

这些数字真的很高,与新一代相比,老人永远不应该达到一个很高的数字。我猜你有内存泄漏。

I can only guess you program is dealing with big files, you are probably saving to references to them for to long.

我只能猜测您的程序正在处理大文件,您可能将它们的引用保存了很长一段时间。

#2


3  

Even still having the main problem (memory leak) resolved, if you still want the old gen to be cleared in frequent small sized pauses, you may try setting

即使仍然解决了主要的问题(内存泄漏),如果仍然希望在频繁的小停顿中清除旧的gen,您可以尝试设置

-XX:MaxGCPauseMillis=(time in millis)

and this is only applicable with Parallel Collector and when Adaptive Sizing Policy is on. By default Adaptive Sizing Policy is on, but, if you want to explicitly mention this you can use.

这只适用于并行收集器和自适应规模策略。默认情况下,自适应调整大小策略是打开的,但是,如果您想明确地提到这一点,您可以使用它。

-XX:+UseAdaptiveSizePolicy

Or else you can switch to CMS collector where you can use

或者你可以切换到CMS收集器,在那里你可以使用。

-XX:CMSInitiatingOccupancyFraction=(% value) 
-XX:+UseCMSInitiatingOccupancyOnly

Which is a more reliable way of collecting the old gen when it has reached a certain fraction of the the old gen.

这是一种更可靠的方法来收集旧一代,当它到达旧一代的一定比例时。

#3


3  

在堆内存使用中PS旧的Gen内存:GC设置The stateful session beans were making the JVM run out of memory. Explicitly handling them using @Remove annotation resolved this issue.

有状态会话bean使JVM内存不足。使用@Remove注释显式地处理它们解决了这个问题。