Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > disposal of object

Reply
Thread Tools

disposal of object

 
 
patrick
Guest
Posts: n/a
 
      12-20-2007


An object has been added into a Vector v:
v.add(obj);


Later I want to dispose of the object.

Must it first be removed from the v for garbage disposal
to get rid of it.

Or would setting obj=null; be enough to dispose of it?






 
Reply With Quote
 
 
 
 
jkohen@gmail.com
Guest
Posts: n/a
 
      12-20-2007
The instance won't get disposed until you release all its references.

If obj is local to a function and the thread has left the function,
then that reference is gone and you don't need to set it to null
explicitly. If obj happens to be a static field and you cannot reduce
its scope, then you might want to set it to null, or it will be alive
for as long as the class itself is referenced.
 
Reply With Quote
 
 
 
 
patrick
Guest
Posts: n/a
 
      12-20-2007
thats clear.
thanks
patrick

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The instance won't get disposed until you release all its references.
>
> If obj is local to a function and the thread has left the function,
> then that reference is gone and you don't need to set it to null
> explicitly. If obj happens to be a static field and you cannot reduce
> its scope, then you might want to set it to null, or it will be alive
> for as long as the class itself is referenced.



 
Reply With Quote
 
Thomas Kellerer
Guest
Posts: n/a
 
      12-20-2007
patrick, 20.12.2007 11:55:
> An object has been added into a Vector v:
> v.add(obj);
>
> Later I want to dispose of the object.
>
> Must it first be removed from the v for garbage disposal
> to get rid of it.


Yes, you need to remove it from the Vector


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PC Disposal, Software Disposal Lawrence D'Oliveiro NZ Computing 0 10-29-2009 02:53 AM
ASP.NET Object Disposal mukulprabhu@gmail.com ASP .Net 2 08-21-2006 02:05 AM
Session object correct disposal Amadrias ASP .Net Security 0 05-03-2006 11:58 AM
Proper database connection disposal methods?? Roger Twomey ASP .Net 3 02-18-2005 10:07 PM
DirectoryEntry Disposal Test cameron ASP .Net 3 04-14-2004 09:55 AM



Advertisments