I am working in an android application an I am having some memory issues.I have a lot of private and public static variables declared in an activity.
I want to know whether when an activity id finished, these private and public object cleared(Memory) or should we make it null manually by assigning it to null in on onDestroy(). Is this correct method or please advice an alternative. Also I call the garbage collector manually in every onDestroy(). Is it correct way to call the System.gc manually?
Please help me.
Whenever the object don’t have any references you can declare it as null.
You can verify the memory information by using dumpsys meminfo (pid) command inside adb shell
If you cal manually gc it will not give you a guaranty of garbage collection