Home > Mobile >  About the Android WeakReference to prevent a memory leak would object recovery has not been used by
About the Android WeakReference to prevent a memory leak would object recovery has not been used by

Time:03-16

Such as the following section of code is written in the Activity
 
Handler Handler=new Handler () {
WeakReference The context=new WeakReference (MainActivity. This);
@ Override
Public void handleMessage (Message MSG) {
Super. HandleMessage (MSG);
The Log i. (TAG, "the context=" + context).
System. The gc ();
The Log i. (TAG, "the context=" + context).
}

};

Question, I'll find data said weak references will be recycled, but will not happen when I didn't meet with GC to recycle it?

CodePudding user response:

This may be
  • Related