How to use Garbage Collector?

The Garbage Collector has evolved so much that for the Java 1.6 you know for sure:
  • it uses different methods to manage references and the corresponding Heap addresses; the most trivial method is that is uses a table to count how many references are used to reach a Heap memory zone; when the number of references gets to 0 then the memory zone is released;
  • it is a complex and very efficient JVM routine that will not interfere with your Java process performance;
  • it will not save any out of memory situation (OutOfMemoryException); remember that any live object (it is reachable by a live reference) it is not collected;
  • you can request garbage collector to make a memory clean explicitly by invoking theSystem.gc( ) method;
  • it is not recommended to interfere with the garbage collector by calling System.gc( ) method, because you have not any guarantees on how it will behave


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email