sre22
asked on
Freeing Memory
After your program is done with a certain object, is it good practice to set that object to null in order to free memory? Or what is preferred method if there is one?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>what do you mean by this? Does my program know when will be the last time I use an object and automatically delete it after the last time?
Pretty much, yes. The JVM keeps track of how many references an object has (among other things), and when it reaches 0, that object's memory is freed up for use. The actual method the JVM uses is a bit more complex than a simple reference counter, but I hope you get the picture.
Pretty much, yes. The JVM keeps track of how many references an object has (among other things), and when it reaches 0, that object's memory is freed up for use. The actual method the JVM uses is a bit more complex than a simple reference counter, but I hope you get the picture.
ASKER
sounds good to me. Thanks.
ASKER
what do you mean by this? Does my program know when will be the last time I use an object and automatically delete it after the last time?