• 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

Forcing Full GC

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

We would like to run Full GC for every 1 hour on our production system. What I found was, be setting below JVM parameters, we can force the Full GC on the JVM heap.

-Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000


Can somebody tell me the real purpose of the above statements? Would Full GC run every 1 hour and all the unreachable objects gets cleaned by the full GC which was triggered by above parameters?

I read some where that, only RMI objects which are unreachable gets cleaned by the above JVM Parameters.
Please can somebody help me?
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your question is a little ambiguous.

This suggests that you have tried it and it did force a full GC

krishna bulusu wrote:What I found was, be setting below JVM parameters, we can force the Full GC on the JVM heap.



Yet here you appear to be asking if if a full GC would happen.

krishna bulusu wrote:Would Full GC run every 1 hour and all the unreachable objects gets cleaned by the full GC which was triggered by above parameters?



Have you tried it and if so, what happened ?
I would be surprised if it did force a full GC as those parameters are related only to RMI GC.
 
krishna bulusu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply.
I will Explain my question in more detail.
We have the below JVM parameters on our production system:

-Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000


We observed on the logs that, Full GC is happening in every 1 hour. Below is the sample Log satement.

3780.425: [Full GC [PSYoungGen: 17367K->0K(484544K)] [ParOldGen: 687597K->404076K(1094848K)] 704964K->404076K(1579392K) [PSPermGen: 50827K->50247K(101120K)], 1.3162930 secs]

After 24 hours of the server restart, I have taken the heap dump of my production JVM. Its about 1.5GB.
After given it to the Eclipse Memory Analyzer, the size comes to 140MB!!(Eclipse Memory analyzer parsed it and removes all the unreachable objects.) The Eclipse Memory analyzer shows that, the Unreachable objects size is about 1.3GB!!

Can I assume that, after running the Full GC every hour by below JVM parameters, the unreachable objects should be cleaned up? Does the below JVM parameters forces Full GC which claims the unreachable objects (or) its related to RMI objects only?

-Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, RMI objects only.

I'd *really* still recommend using a full-on memory profiler, not a heap dump analyzer, to find out what physical memory is actually being used, and by what.
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't think it was possible to "force" the garbage collector to execute.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:I didn't think it was possible to "force" the garbage collector to execute.



RMI distributed garbage collection runs at regular intervals. These two variables can be used to alter what that interval is.
 
krishna bulusu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your replies.
Is there any way to 'request' Explicit GC(System.gc()) if we can't force it?
For our production, it would be very useful for us to clean up the unreachable objects in regular basis instead of having them on our heap and let the GC clean them when it is short by memory.


 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.gc() is how you request GC. But the chances if you handling memory better than the JVM are very, very low: it'll reclaim memory when needed. This kind of manual memory management is almost *never* needed in server apps.
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think you asked a very sensitive question.... Ive seen quite a few threads flood with highly emotional responses about how "You can never force a GC" and "All you can do is suggest a GC".

Indeed. System.gc is the best way to go about it. But it depends on the platform. It has been known to not do anything(Quote kathy sierra and bert bates - scjp 6 ). In most of the platforms however for a very high percentage of times, it will run the GC. I know that whenever I have tried on windows, to test it, Ive seen it run. But this is not guaranteed. This is like saying the higher priority thread started first will run first. Even though this is true most of the times, its not something you can rely on.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic