garbage collection - memory issues

doggz used Ask the Experts™
When running with -verbose GC, I get the following printings:

[GC 64083K->56646K(66432K), 0.1530969 secs]
[Full GC 66310K->49269K(95432K), 1.8605430 secs]

what does these numbers mean (which memory ir relates to. the program's heap? the process memory?)
What is the garbage collector's policy regarding when to cleam objects?
should I be alarmed if the second number along time, is a monotonic serious (increasing!!!)?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Garbage collection occurs whenever the VM determines that an object on the heap is no longer being used.  This is pretty darn effective, but one thing you need to know with garbage collection is that garbage collection is guaranteed only when the objects has null reference to it i.e. you set your object to equal null.  

You can also force garbe collection using the System.gc() and Runtime.gc() methods, but again cleanup is not guaranteed unless the objects have a null value.  Remember, the garbage collector has been optimized to clean up memory but will also not clean up memory it thinks you're still using - it's up to the programmer to close streams, database connections, and get rid of objects etc.


That I already know. Yet my questions remain.
Sorry, got a bit carried away explaining gc.

Your questions:
1.  This shows minor and major object collections by the gc.  The numbers before and after the arrow indicate the combined size of live objects before and after the GC. (After minor collections the count includes objects that aren't necessarily alive but can't be reclaimed, either because they are directly alive, or because they are within or referenced from the old generation.) The number in parenthesis is the total available space, which is the total heap minus one of the survivor spaces.
2. I think I explained the gc's policy - it cleans up when it determines an object is longer being used - set objects to null to ensure they get cleaned up.  
3. As far as I know, the second number shouldn't increase continually - it should go up and down as activity on your application changes.  However, it stands to reason it will go up and up from when you start the app as more users connect or more activity occurs, but should eventually stablise.


So if I summarize what you're saying its:
1. The first and second numbers are the total sizes of the objects allocated by the program. first number is before GC and second after.
2. What I still don't understand is the policy of the garbage collector regarding the removing of non-referenced objects. For how long will it run? how much will it clean for one run, when it finishes, does it mean that there are no more references to remove at that exact time?
1. yep
2. It'll run as long as it needs to in order to clean up all the objects - so yes, until there are no more references to remove at that exact time.  As to exactly how often it runs I'm not sure although I'm sure it'll be documented somewhere on

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial