setting an object to null, what happens?
-
Hi, After I am done with the object, when I set that object to null, what I am doing there. (Is it, I am setting manually no references to the object or I am reclaming the memory used by the object or I am doing both) Thanks Devin.
devin123 wrote: After I am done with the object, when I set that object to null, what I am doing there. You are setting the reference to the object to null, not the object itself. If there are no references to an object the garbage collector can remove the object from memory. If the reference is a local variable then when the method goes out of scope the reference will no longer exist and the object (assuming no other references) will get cleaned up. Does this help?
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
devin123 wrote: After I am done with the object, when I set that object to null, what I am doing there. You are setting the reference to the object to null, not the object itself. If there are no references to an object the garbage collector can remove the object from memory. If the reference is a local variable then when the method goes out of scope the reference will no longer exist and the object (assuming no other references) will get cleaned up. Does this help?
My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More