Home > Archive > Java Help > December 2004 > can an object instance be removed ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
can an object instance be removed ?
|
|
| Rick D. 2004-12-27, 8:57 pm |
| 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
| |
| klynn47@comcast.net 2004-12-27, 8:57 pm |
| The 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.
| |
| jhsolorz@hotmail.com 2004-12-28, 4:00 pm |
|
Rick 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
|
|
|
|
|