Possible Duplicate:
Java garbage collection
I know that we have to free object in C, C++ after processing finish to get back the memory. However, I don’t know how to free object in java and android. Is that enough for just assign null to the object?
In Java it is un-necessary to free objects.
Java has a built in Garbage Collector which runs when ever it needs to and clear out all resources that are no longer in use in order to free memory. A java developer may make a call to the java runtime to run the Garbage Collecter using
System.gc();however this is just a suggestion to the runtime and may not always result in it being run.In cases where you are using readers and images, be sure to call
.recycle()and.close()where applicable.