This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi all -
I've looked through the forums here and at Sun and have found some helpful info, but nothing that completely
explains what I'm seeing.
I'm running a Swing app in 1.6.
My VM args are:
I start the app and make no large data calls, just leave it running, sort of idling. I then start jconsole and watch the heap memory usage.
It begins ~10mb and over about 10 minutes increases to 75mb. Then it seems the garbage collector kicks in and the usage goes
back down to 10mb.
Here is the question: When I change the VM args to not have an initial setting (-Xms) the memory doesn't grow so large.
It goes up to about 20mb, then is garbage collected back down to 10mb.
Here are these VM args:
As you see, all I've done is remove the initial setting (-Xms512M).
When I look in jconsole at the "VM Summary" I don't see any initial setting at all. The compiler is configured to set it to max=512mb.
Maybe this is a problem?
I don't really care what the initial setting is as long as it's enough - what I want to know is: why the discrepancy in memory usage between my
two VM arg sets?
Does anyone have any insight into this? I would very much appreciate it, as I can't seem to find much documentation on it anywhere.
The default for -Xms is fairly small, I don't even recall exactly what it is. JDK 6 usually adjusts the young generation size to be about 1/6 - 1/3 the size of the heap. So with a 512MB heap, you are seeing a 70MB young generation being filled and then garbage collected. Without -Xms set you are getting a smaller heap (let's say 64MB for discussions sake) so the young generation will be about 20MB and when it fills up the GC runs and cleans it.
The key, of course, is the actual heap size and young generation size. You can set command line options that will tell you the heap sizes during each collection. See my white papers for how to gather and make use of that information:
Java Garbage Collection Statistical Analysis 101
Java Garbage Collection Performance Analysis 201