问题描述
我有一个24x6时间表的应用程序。目前,在运行几天之后,Full GC会自动执行 - 通常在一天的繁忙时段进行,这会对用户的响应时间产生负面影响。
我想要做的是强制一个完整的GC - 可能在每天晚上的午夜,在非常低的使用时间内 - 防止它在白天发生。我试过System.gc(),但它似乎并不能保证什么时候Full GC会发生,或者甚至会发生。有没有一些方法可以做到这一点?
版本信息:
Java™SE运行时环境
Java HotSpot™服务器虚拟机(构建11.0-b16,混合模式)
另外 -
- 小GC正在运行,大约每10-15秒。但是这些都没有释放出足够的RAM来让应用程序整整一周。当Full GC发生时,将近50%的堆被释放。
- 关于上述情况,调用System.gc()似乎并不意味着下一个GC将成为释放这些大块内存所需的完整表单。是的,它已启用(或未禁用,具体取决于您阅读-XX选项的方式)。
- 我已经尝试了几种CMS GC设置,这对设置有很大的帮助,但没有解决问题。最初它每周抛出两到三次OOM。
- 我想停止无限循环:
- 不断添加到堆空间 - 只能持续很长时间
- 不断调整和测试GC设置 - 它早已超过递减点
- 我不想像NT机器那样对待它,并且每晚都会弹出它。在整个晚上都有活动的用户会话,并且弹跳应用程序意味着会丢失会话数据。 寻找更多的技术来确保Full GC将会发生,而不是一个简单的方法/函数来调用它。
现在我查看CMS使用的百分比阈值修改,以确定何时需要完整的GC。
感谢您的任何帮助。
解决方案jmap -histo:live< PID>
将强制Full GC作为副作用所有活的物体。您可以安排它在非工作时间回收您的JVM进程。
您的JVM
内部版本1.6.0_11-b03
是非常古老的,但在所有1.6版HotSpot JVM上都应该支持jmap
。I have an application that's running on a 24x6 schedule. Currently, after running for a few days, a Full GC is performed automatically - and usually during a busy part of the day, which negatively impacts user response times.
What I'd like to do is force a Full GC - perhaps at midnight each night, during very low usage times - to prevent it from happening during the day. I've tried System.gc(), but it doesn't seem to guarantee when a Full GC will happen, or even if it will. Is there some means of doing this?
Version info:
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Server VM (build 11.0-b16, mixed mode)Additionally -
- Minor GCs are running, about every 10-15 seconds. But these are are not freeing up enough RAM to get the app through a full week. When a Full GC does happen, nearly 50% of the heap is freed.
- In relation to the above, calling System.gc() doesn't seem to mean that any of the next GCs, will be of the Full form needed to free those large chucks of memory. Yes, it is enabled (or not disabled, depending on how you read the -XX option).
- I've already played around with several of the CMS GC settings, which has helped greatly, but not solved the problem. Originally it was throwing OOMs, two to three times a week.
- I want to stop the endless loops of:
- constantly adding to heap space - which can only go on for so long
- constant tuning and testing of GC settings - it is long past the point of diminishing return
- I don't want to treat this like an NT machine and bounce it nightly. There are active user sessions throughout the night, and bouncing the app would mean loosing session data.
To be more specific, I'm looking more for a technique to use to ensure that a Full GC is going to happen, rather than a simple method/function to call to run it.
At the moment I'm looking at the modification of the percentage threshold used by CMS to determine when a Full GC is required.
Thanks for any help.
解决方案jmap -histo:live <PID>
will force Full GC as "side effect" of finding all live objects. You can schedule it to recycle your JVM processes on off-working hours.Your JVM
build 1.6.0_11-b03
is pretty ancient, butjmap
should be supported on all 1.6 HotSpot JVMs.这篇关于有没有办法在Java中安排完整的垃圾收集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!