• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Concurrent Mark Sweep Vs Garbage 1 GC

 
Greenhorn
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
G1GC-profile.jpg
[Thumbnail for G1GC-profile.jpg]
CMS.jpg
[Thumbnail for CMS.jpg]
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 17
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic