aspose file tools*
The moose likes Performance and the fly likes Concurrent Mark Sweep Vs Garbage 1 GC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Concurrent Mark Sweep Vs Garbage 1 GC " Watch "Concurrent Mark Sweep Vs Garbage 1 GC " New topic
Author

Concurrent Mark Sweep Vs Garbage 1 GC

Manju Prabhu
Greenhorn

Joined: Dec 22, 2008
Posts: 3
I am comparing Concurrent Mark Sweep Vs Garbage 1 GC in JDK 7
These are the test that I ran -
TEST1
I am profiling GCTest.java using VisualVM that is provided in jdk.
The code creates 150 integer Arrays into an Arraylist. Each integer array reservers 4 MB of memory i.e. 1*1024*1024*4 Bytes.= 4MB *150(iterations) = 600 MB.
then I am removing the arrays. At every 10th iteration, I am explicitly calling the garbage collector - System.gc();

command line used :
For G1:
java -XX:+UseG1GC -XX:+PrintGCDetails -Xloggc:G1GC.log -XX:GCTimeRatio=49 -XX:MaxGCPauseMillis=50 GCTest
For CMS:
java -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -Xloggc:G1GC.log -XX:GCTimeRatio=49 -XX:MaxGCPauseMillis=50 GCTest

The results from the execution can be found here(Please download original) -
https://docs.google.com/open?id=0B_MpilGzweULNTQ0NzE4YzMtOTFhMS00NTllLWJhNDYtNjZlNmE3OGMyYzU0

My First question is -
Since i am calling GC explicitly, Is this the right approach to compare Garbage collectors ?

These are the conclusions from the tests -
1) If a server has good CPU and RAM then G1 is a good option
2) If a server has average CPU and good RAM, then CMS is better.
3) Application Performance is better in CMS than G1 owing to high CPU utilization.

Second question -
Are the conclusions correct ? What other conclusions can be derived from the results?

TEST2
I ran a second test. I tweaked class a bit. The results were surprising -


1) When G1 collector is used, the Max heap size is reclaimed, but in case of CMS it is not reclaimed
2) In CMS Max used heap size is around around 20 MB, but in G1 it is 600 MB!!. Max heap size(available) in case of G1 it is 750 MB and CMS it is 65 MB
3) Max Throughput of G1 was 2.8% , but in case of CMS was well within 2%
The results can be seen in the attachment - G1GC profile and CMS Profile
Questions -
Why is the Max used heap size 600 MB in case of G1 collector?


[Thumbnail for G1GC profile.jpg]

[Thumbnail for CMS.jpg]

fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10913
    
  12

calling System.gc() does not guarantee that the GC runs...it is merely a suggestion to the JVM that you think now might be a good time - but the JVM is free to ignore the request.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rojan punn
Greenhorn

Joined: Nov 29, 2011
Posts: 17


Hi,

Is this testing really for your application which runs in production env?Or just to learn abot the GC mechanism?Is this for a multi threaded env?
I wanst aware about G1 GC's existance in jdk6 .

The test really doesnt give an actaul performance figures .you will have a better idea if you make your program as a thread and register as a service in windows.and monitor it with defferent parameters and code cahnges.

from the picture provided the g1 GC has a very inconsisten use of Heap/or a very large amount of heap is used at a time ? which is not good for real time systems as other threads may run slowly in this case.
but the cms picture has a consistent use of heap .
So if you want to find out which is good you really have to experiment with these as you are doing now.Any way also have a look at the below lnk if you havent seen it already.

http://www.oracle.com/technetwork/java/javase/tech/g1-intro-jsp-135488.html

Rojan
 
 
subject: Concurrent Mark Sweep Vs Garbage 1 GC
 
Similar Threads
ambiguity in the functionality of garbage collector
Garbage Collection and Post Increment Operator doubts
Please review this code
CMS collector tuning
Null pointer Exception