avram / zandy

Zotero on Android
http://www.gimranov.com/avram/w/zandy-user-guide
GNU Affero General Public License v3.0
148 stars 28 forks source link

Activity memory leak caused by anonymous threads #162

Open cuixiaoyiyi opened 2 years ago

cuixiaoyiyi commented 2 years ago

An anonymous inner class will hold a reference to the this pointer of the outer class and will not be released until the thread ends.

It will hold the Activity and prevent its timely release.

com.gimranov.zandy.app.MainActivity:
 void onClick()
 void onNewIntent()
 void toastError()  // ApplicationContext instead

The anonymous thread can be replaced by static class with weak references of activity.