views:

130

answers:

2

Hi Guys,

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 is the default and -Xmx is 2048mb.

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

http://imagebin.org/92614

Shrinking heap

n.b originally posted on serverfault.com, moved to stackoverflow.com as requested

+3  A: 

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

When does the Java heap shrink?

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.

If IBM is doing it, it could be that Sun does something similar.

Edit: They do.

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.

Thomas
A: 

Just a guess: It looks like the system is pretty much idle. There might be some caching going on, and stuff drops out of the cache and gets gc'd. Or since it is a queuing system, maybe it has some messages, in the queue, which slowly get delivered and gc'd afterwards.

The increased frequence of gc-runs might be due to ever decreasing load on the system.

As to how to avoid it. Why do you want to avoid it? It seems like your CPU load is zero. So you are free to let the gc do whatever it wants

Jens Schauder
I think that "Eventually the VM locks up" (if true and as the OP stated) would be something to want to avoid.
Kevin Brock
Damn, you are right, completly missed that part
Jens Schauder