Monday, September 16, 2013

Inside Java - JVM Memory Structure 3

Hi everybody!

Today I will bring a little bit of suggestion of GC (like promised in the last post). I will just give an idea of the types of Garbage Collector in Java and some (tons) references to good articles in the web to get more in depth ( I will put here also the depth details but it will be other post to make things easier to read =) ).

Just remembering the last post, the objects created are all placed in Young Generation where then when these objects become old and not removed from the GC, they become part of the Old generation (called Minor GC event). When the Old generation is full (or other metrics) it needs to be fully garbage collected (called Major GC). Also, most of the concepts here are more OpenJDK IceTea/Oracle Hotspot related, other JVM vendors might have different strategies.

Going back to the main point of thi article, the types of GC are:

  • Serial  - Very old single thread GC that was the default GC. After Java 5+ it ins`t default anymore due the low Throughput .
  • Throughput Collector - Uses a parallel GC threads to clean the heap. There is two different options:-XX:+UseParallelOldGC  and -XX:+UseParallelGC, where the UseParallelOldGC is to the algorithms clean the Tenured/Old space and the other one (UseParallelGC) is to the Young generation. This type has its name due it suits for high Throughput system where it needs intensive use of CPU and it tolerate some (like 1% of the) cases where the delay/latency is much higher than the useful (due the GC running).
  • Concurrent Low Pause Collector - Collects (almost) concurrently, first with a very small stop-the-world event then it runs concurrently with the execution of the app (remember the other type above it run in parallel but it stopped your application and here your application is paused for short period). This is perfect for low latency applications (but it will consume more CPU,e.g.). Use the XX:+UseConcMarkSweepGC JVM`s option to enable it for Old generation (the young generation needs to run other algorithm with this one, it is complicated so I will explain in next post of the sequel).
  • The Incremental - This is one GC type only found in old client JVMs where you could do some fine tunes. Today we have much more options to tune all the algorithms and also GC ergonomics (some refers will explain this, but there will be a post here also about it in the future).

I didn`t have time to create an image so, I would recommend to see the image from this blog for see the differences of the type I cited above (I will provide an update here and put an image here).

There are tons of keyword that might be new for your so I would recommend to see OpenJDK`s Glossary. That will help to get started and used to most of keywords that will help a lot to find the answer to your problems. For more details, to help to monitor and tune your JVM, I will leave you some references:

http://www.petefreitag.com/articles/gctuning/
http://rkennke.wordpress.com/2013/06/10/shenandoah-a-pauseless-gc-for-openjdk/
http://stackoverflow.com/questions/16442934/serial-mark-sweep-compact-psoldgen-ps-stands-for
http://stackoverflow.com/questions/16549066/java-major-and-minor-garbage-collections
http://stackoverflow.com/questions/13642241/java-gc-major-gc-vs-minor-gc
http://www.infoq.com/articles/Java_Garbage_Collection_Distilled
http://useless-factor.blogspot.com.br/2008/03/little-more-about-garbage-collection.html
http://sureshsvn.com/jvm.html
http://javarevisited.blogspot.com.br/2011/04/garbage-collection-in-java.html
http://www.cubrid.org/blog/dev-platform/understanding-java-garbage-collection/
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
https://wiki.umn.edu/pub/UmmCSciSeniorSeminar/Fall2011Talks/JeffreyLindblom.pdf
http://apmblog.compuware.com/2011/05/11/how-garbage-collection-differs-in-the-three-big-jvms/
http://sanjaal.com/java/tag/java-garbage-collection-the-throughput-collector/
http://www.softwaresecretweapons.com/jspwiki/thelastjavagarbagecollectionguideyouwilleverneed
http://www.ibm.com/developerworks/library/j-jtp10283/
http://www.ibm.com/developerworks/java/library/j-jtp11253/
http://www.slideshare.net/caroljmcdonald/java-garbage-collection-monitoring-and-tuning
http://robaustin.wikidot.com/jvm-garbage-collector-overview
http://wiki.osdev.org/Garbage_collection
http://c2.com/cgi/wiki?MarkAndSweep
http://javabook.compuware.com/content/memory/making-garbage-collection-faster.aspx
http://www.cubrid.org/blog/dev-platform/how-to-monitor-java-garbage-collection/
http://www.oracle.com/technetwork/articles/java/g1gc-1984535.html
http://viralpatel.net/blogs/java-garbage-collection-simplified/
http://apmblog.compuware.com/2011/03/10/major-gcs-separating-myth-from-reality/
http://blog.ragozin.info/2011/12/garbage-collection-in-hotspot-jvm.html
http://blog.ragozin.info/2011/09/hotspot-jvm-garbage-collection-options.html
http://androidyou.blogspot.com.br/2010/06/gc-log-visulation-hpjmeter.html
http://www.stefankrause.net/wp/?p=14
http://docs.neo4j.org/chunked/stable/configuration-jvm.html
http://blog.griddynamics.com/2011/06/understanding-gc-pauses-in-jvm-hotspots.html
http://blog.griddynamics.com/2011/06/understanding-gc-pauses-in-jvm-hotspots_02.html
http://www.oracle.com/technetwork/java/javase/tech/memorymanagement-whitepaper-1-150020.pdf
https://blogs.oracle.com/jonthecollector/entry/our_collectors
http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#available_collectors
http://docs.oracle.com/javase/1.5.0/docs/guide/vm/gc-ergonomics.html
http://www.stefankrause.net/wp/?p=14
https://code.google.com/a/eclipselabs.org/p/garbagecat/wiki/Documentation
https://wiki.openjdk.java.net/display/HotSpot/PerformanceTechniques
https://wiki.openjdk.java.net/display/HotSpot/Garbage+Collection
http://www.infoq.com/articles/Introduction-to-HotSpot

2 comments:

  1. LOL, some references :D, Thanks

    ReplyDelete
  2. I will try to write more about JVM and make the information available in those references in more simple way here =) It will just take some time and posts =D Welcome!

    ReplyDelete