I have found some list in my source code which has list.add() but not list.remove(). Is it causing a memory leak? I tried list.clear() and list=null but it seems to have no effect.
What should be done to clear this list? Kindly explain… Thanks in advance.
I have found some list in my source code which has list.add() but not
Share
list.clear()will clear all the reference from the list. If they are not used by any other objects it will be cleared from memory bygarbage collector. Butclearalone will notdeletethe objects. I think the problem is, some other objects are using the data so it is still there in the memory.Post sample code to make us know what is the exact problem.