http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html for Java 6, very well explained conceptually.
http://www.fasterj.com/articles/oraclecollectors1.shtml brillant lookup of the main flags available, and possible combination of GC for yound and old generation (Java 7)
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html list of all JDK 7 options.
To test the options, you can run InfiniteLoop.java :
public class InfiniteLoop { public static void main(String[] args) throws Exception { for (;;) {Thread.sleep(1000);} } }
and run jconsole....in the "threads" tab you have a nice summary of the Eden Space, Survivor Space, Old Gen.
you can also run jinfo:
jinfo -flag UseParallelGC 3797 jinfo -flag MinHeapFreeRatio 3797 jinfo -flag UseSerialGC 3797
where 3797 is the process PID.
Attempts to change GC strategy runtime :
jinfo -flag +UseSerialGC 3797
will miserably fail:
Exception in thread "main" java.io.IOException: Command failed in target VM at sun.tools.attach.BsdVirtualMachine.execute(BsdVirtualMachine.java:208) at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:217) at sun.tools.attach.HotSpotVirtualMachine.setFlag(HotSpotVirtualMachine.java:190) at sun.tools.jinfo.JInfo.flag(JInfo.java:129) at sun.tools.jinfo.JInfo.main(JInfo.java:76)
On a different topic, read also:
1 - http://www.oracle.com/technetwork/java/javase/crashes-137240.html this document about troubleshooting system crashes
2 - http://www.oracle.com/technetwork/java/hotspotfaq-138619.html this interesting FAQ list
3 - this document http://www.oracle.com/technetwork/java/jdk50-ts-guide-149808.pdf (a bit outdated) about jmap, jinfo, jstack etc
4 - http://www.oracle.com/technetwork/java/javase/index-137495.html this one repeats more or less - with more details - the info in the above document n. 3
Priceless are these commands:
jmap -heap 3843 jmap -histo 3843 jmap -permstat 3843 jmap -dump:file=dump.map 3843 jhat -port 7401 dump.map (at this point open your browser at localhost:7401) jstat -gc 3843 jstat -printcompilation 3843 jstat -gcutil 3843 250 7
No comments:
Post a Comment