Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

disposal of  object

Thread view: 
patrick - 20 Dec 2007 10:55 GMT
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?
jkohen@gmail.com - 20 Dec 2007 11:23 GMT
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.
patrick - 20 Dec 2007 11:36 GMT
thats clear.
thanks
patrick

> The instance won't get disposed until you release all its references.
>
[quoted text clipped - 3 lines]
> 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.
Thomas Kellerer - 20 Dec 2007 11:37 GMT
patrick, 20.12.2007 11:55:
> An object has been added into a Vector v:
> v.add(obj);
[quoted text clipped - 3 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.