rdoeffinger / Dictionary

"QuickDic" offline Dictionary App for Android. Provided downloadable dictionaries are based on Wiktionaries but can also be created from other sources (see DictionaryPC). Remember to use --recursive when cloning! Fork of project that used to be hosted at code.google.com/p/quickdic-dictionary.
Apache License 2.0
322 stars 69 forks source link

Activity memory leak caused by anonymous threads #154

Closed cuixiaoyiyi closed 12 months ago

cuixiaoyiyi commented 2 years ago

Possible Memory Leak

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. Please check the links below.

Occurrences

onCreate

Possible Solution

If it is necessary, it can be changed to static class + weak reference to eliminate the reference to the activity, which may cause memory leaks. Further discussion is welcome.

rdoeffinger commented 12 months ago

The thread is immediately started and will terminate after a short time (usually milliseconds). None of the problematic scenarios described in the links seem possible.

rdoeffinger commented 12 months ago

Don't think there is anything to do here.