From the posting, I am not sure if this is a question on Garbage Collection in general, or if you are after something more specific. But, Java typically handles garbage collection on its own. Once the JVM determines that there are no references to the object, it becomes available to for collection. But, there is no guarantee that it will be collected, nor is there any guarantee as to when the garbage collector will run. You can invoke the garbage collector with:
But, that doesn't mean anything is going to happen. JVM's use different algorithms to determine garbage collection, and you do not have complete control over the process. It's a good habit to set objects to null, when you know you are done with them, but there is not much to worry about as far as memory leakage though, unless you are running native methods (written in C or some other language.)
Here are a couple sites that offer some good info about the process:
Those numbers in that widget represent the amount of memory that the heap is currently using and the heap's current maximum size given to NetBeans itself. If you click on it you can force garbage collection. I don't think it's accurate enough for you to track down memory leaks. I know the NetBeans profiler has a bunch of useful stuff for this, however.
In general it's good to ignore GC in your code. Take care to not hold object references any longer than you really need them and let it do its thing.
Outside the code, you can do a lot of tuning on the JVM parameters. Read up on those and be careful to read for your specific JVM vendor and version for the really tricky bits.
If you have Java 5 or later, fire up JConsole. You can watch the various areas of memory grow until the JVM needs more room, then see GC clear up some space. It's not a bad thing if memory usage goes right to the limit before GC. It may well be a bad thing if the low end of the usage curve after GC creeps up over time or doesn't come back down far enough to allocate some ginormous object.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi