|
Re: delete objects;
|
Posted: Feb 28, 2005 1:09 PM
|
|
actually, that's not exactly the full story
there is an implied way to remove the object from memory which comes in handy if your allocating alot of objects and need that space freed up as soon as possible
myObject = new MyClass(); myVector.add(myObject);
... myVector.remove(myObject); myObject = null;
the myObject = null drops a hint to the garabage collector that it's ok to free that objects space right away... which it usually does otherwise what happens is that unreferenced objects get collected till memory is needed and then a full gc process kicks in, pausing all operations until it's done. by helping out the gc with this simple operation, you are actually helping yourself by removing the need for a full garabage collection at a later time.
it works beautifully and came in really handy when i was developing an audio/video conferencing app in java and did not need the gc going bizzerk every five minutes....
- perry
|
|