Code Comments
Programming Forum and web based access to our favorite programming groups.Hi all, I've got a question about removing an object instance. Is there a way to force an object instance to be removed (within it's scope) just like it would be removed if it would get outside the scope. Kind of like a "reversed new". Best regards, Rick
Post Follow-up to this messageThe only thing you can do is remove references to the object and it will be marked for garbage collection. However, there is no guarantee that it will be garbage collected.
Post Follow-up to this messageRick D. wrote: > Hi all, > > I've got a question about removing an object instance. Is there a way > to force an object instance to be removed (within it's scope) just > like it would be removed if it would get outside the scope. Kind of > like a "reversed new". > > Best regards, > Rick Not explicitly in Java. You can make sure there are no references to the object (e.g. if there's a local variable that references the object, assign it to null.) Then you can call System.gc() to force immediate garbage collection. Why do you need to do this specifically? Jose Solorzano
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.