Tuesday, September 17, 2013

JVM argument to solve frequent garbage collection due to System.gc() or Runtime.gc()

System.gc() or Runtime.gc() is called in java codes to do explicit garbage collection.
Since JVM has the capability to do garbage collection on its own we should avoid the
use of sytem.gc() in our codes

If you have the below kind of lines in your gc  logs
<sys id="1" timestamp="Jul 15 12:56:26 2005" intervalms="0.000">
  <time exclusiveaccessms="0.018" />

  <tenured freebytes="821120" totalbytes="4194304" percent="19" >
    <soa freebytes="611712" totalbytes="3984896" percent="15" />
    <loa freebytes="209408" totalbytes="209408" percent="100" />
  </tenured>
  <gc type="global" id="1" totalid="1" intervalms="0.000">
    <classloadersunloaded count="0" timetakenms="0.012" />
    <refs_cleared soft="0" weak="4" phantom="0" />
    <finalization objectsqueued="6" />
    <timesms mark="3.065" sweep="0.138" compact="0.000" total="3.287" />
    <tenured freebytes="3579072" totalbytes="4194304" percent="85" >
      <soa freebytes="3369664" totalbytes="3984896" percent="84" />
      <loa freebytes="209408" totalbytes="209408" percent="100" />
    </tenured>
  </gc>
  <tenured freebytes="3579072" totalbytes="4194304" percent="85" >
    <soa freebytes="3369664" totalbytes="3984896" percent="84" />
    <loa freebytes="209408" totalbytes="209408" percent="100" />
  </tenured>

  <time totalms="3.315" />
</sys>
 
The tag <sys> meant that garbage collection is done due to System.gc() calls.
 
The intervalms is the time used to know how frequent the garbage collection 
happened for this kind.
0.00 ms represent that this is the first time gc happened due to system.gc call.

Please add the below JVM argument if you face frequent gc due to system.gc call

IBM JVM:-Xdisableexplicitgc
Sun JVM: -XX:+DisableExplicitGC 
 

2 comments:

  1. hi can u recommend a nice book on websphere MQ that's quite easy to understand..thanks in advance :)

    am new to mq, really stumbling when it comes to how applications use them for message.

    - Sathya

    ReplyDelete
  2. To understand Websphere MQ and messaging concepts like synchronous &asynchronous u can refer below redbooks:
    http://www.redbooks.ibm.com/redbooks/pdfs/sg247128.pdf.

    ReplyDelete

Your suggestions please