Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calming an excited Garbage Collector

I've got a program that runs very happily with -Xmx2g. With -Xmx1g, it grinds to a halt. It never gets an out of memory exception -- or, at least, I've never had the patience to wait long enough.

This suggests that the total footprint does fit into 1g, but that the GC has some anxiety about possibly running out of space.

The memory footprint is a combination of some large, stable, items with a good deal of ephemeral traffic.

Are any of the more-or-less obscure GC options relevant to this situation?

like image 873
bmargulies Avatar asked Dec 01 '25 01:12

bmargulies


1 Answers

There are a bunch of options you can set on the JVM for garbage collection with http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html. When an app grinds to a halt due to GC, you're usually seeing a lot of major collects, which can stop everything when being collected. You can tune the minor and major collect parameters to see if you can have more frequent minor collections.

I recommend taking a look at what is eating up the heap using a tool like VisualVM (shipped with JDK6, I believe update 7+) and analyze the object graphs. Also look at tools for analyzing an hprof file (How do I analyze a .hprof file?).

like image 142
Jeff Storey Avatar answered Dec 03 '25 15:12

Jeff Storey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!