Java堆不断缩小!在此堆大小图中发生了什么? [英] Java heap keeps on shrinking! What is happening in this graph of heap size?

查看:104
本文介绍了Java堆不断缩小!在此堆大小图中发生了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是运行ActiveMQ的JVM(win64、6u17)的屏幕快照,在每次垃圾回收之后,堆大小都在减小.随着堆大小的减少,垃圾回收变得更加频繁,堆的减少也更快.最终,VM将所有时间都花在GC上,从而将其锁定.

This is a screen shot of a JVM (win64, 6u17) running ActiveMQ, after every garbage collection the heap size is reducing. As the heap size reduces garbage collection gets more frequent and the heap reduces more quickly. Eventually the VM locks up as it's spending all it's time in GC.

-Xms 是默认设置, -Xmx 是2048mb.

-Xms is the default and -Xmx is 2048mb.

发生了什么!!?如何避免这种情况?

What is happening!!? How can I avoid this?

http://imagebin.org/92614

缩小堆http://imagebin.org/index.php?mode= image& id = 92614

n.b最初发布在serverfault.com上,根据要求移至stackoverflow.com

推荐答案

Google从

Google found me the following, from the IBM JVM FAQ (how's that for an NLA):

Java堆何时收缩?

当GC确定存在大量可用堆存储时,就会发生堆收缩,并且释放一些堆内存对于系统性能是有利的.GC之后,但是当所有线程仍然挂起时,就会发生堆收缩.

Heap shrinkage occurs when GC determines that there is a lot of free heap storage, and releasing some heap memory is beneficial for system performance. Heap shrinkage occurs after GC, but when all the threads are still suspended.

Sun JVM做类似的事情.以下摘录自Oracle技术网的文章,标题为 5.0 Java虚拟机中的人机工程学.

The Sun JVM does something similar. Below is an excerpt from an Oracle Technology Network article entitled Ergonomics in the 5.0 Java Virtual Machine.

堆将增长或缩小到可以支持所选吞吐量目标的大小.可以预料,在初始化过程中以及在更改应用程序行为期间,堆大小会发生一些振荡.

The heap will grow or shrink to a size that will support the chosen throughput goal. Some oscillations in the size of the heap during initialization and during a change in the application's behavior can be expected.

...

通常,随着垃圾收集器试图满足竞争目标,堆的大小会振荡.即使应用程序已达到稳定状态,也是如此.达到吞吐量目标(可能需要更大的堆)的压力与目标竞争,以获得最大的暂停时间和最小的占用空间(这两者都可能需要一个小堆).

It is typical that the size of the heap will oscillate as the garbage collector tries to satisfy competing goals. This is true even if the application has reached a steady state. The pressure to achieve a throughput goal (which may require a larger heap) competes with the goals for a maximum pause time and a minimum footprint (which both may require a small heap).

我建议您看看该文件的其余部分;它可能具有与您的问题有关的更多信息.

I suggest you have a look at the rest of that document; it may have more information relevant to your problem.

这篇关于Java堆不断缩小!在此堆大小图中发生了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆