Android APK plug-in startup memory release problem
Android APK plug-in startup memory release problem
The APK is started in the plug-in. Generally, there is no memory problem in the APK, but this problem may exist and be enlarged in the plug-in. The reason is that after reloading classes in the plug-in, the resources of the original plug-in will be reloaded. In the installed APK, unless killed by the system, the resources that were not turned off can be reused; In the plug-in, it is shown as follows:
1. If the variable defined by static is used to store the instance passed in from the outside, remember to set it empty when pushing, otherwise the incoming instance cannot be released; It is also the same when the internal new is saved in a static variable;
2. In a single instance, the new instance is stored in containers such as list. Remember to clear the container under clear() when exiting, otherwise the memory will leak:
For example, defined in a class
Then use it in the method
When exiting, the must be emptied
In addition, the finalize method of the class can be used to detect whether the next class has been released. This method will be called when releasing memory during garbage collection
Thank you for reading, hope to help you, thank you for your support to this site!