The moose likes Beginning Java and the fly likes How to Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How to "kill" an object?" Watch "How to "kill" an object?" New topic
Author

How to "kill" an object?

Conway Chow
Greenhorn

Joined: Aug 17, 2000
Posts: 2
Hi there,
I know that I need to use new to instantiate a new object (i.e. NewObject a = new NewObject). But what command do I use to remove or kill an object? I know that Java has the automatic garbage disposal - but I want to remove the object immediately.
Thanks for you help!
mrp
Greenhorn

Joined: Aug 12, 2000
Posts: 2
I do not think that you can force your object to be reclaimed for garbage collection by the JVM. The only alternative you are having is to inform the JVM that your object is ready to be garbage collected by invoking System.gc(). Hope this info helps.
Mathews.
V Srinivasan
Ranch Hand

Joined: Aug 16, 2000
Posts: 99
System.gc() method invokation also brings the object to the state of readiness for gc. In run time system takes its own time to do gc.
There is one more approach for gc. i.e.
a = null;
when an object is set to null it is ready for gc.
I hope I am in write direction. Please clarify if I am wrong.
Thanks and regards
 
 
subject: How to "kill" an object?
 
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture