zoff99 / ToxAndroidRefImpl

Tox Reference implementation for Android
GNU General Public License v3.0
274 stars 53 forks source link

Activity memory leak caused by anonymous threads #350

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.

They will hold the Activity and prevent its timely release. Please check the links below.

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/FriendInfoActivity.java#L276

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceAudioActivity.java#L1110

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceAudioActivity.java#L646

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceAudioActivity.java#L1290

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceAudioActivity.java#L1438

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceAudioActivity.java#L1204

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceMessageListActivity.java#L1095

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceMessageListActivity.java#L402

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceMessageListActivity.java#L949

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MaintenanceActivity.java#L785

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListActivity.java#L465

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/CallingActivity.java#L1966

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/CallingActivity.java#L1652

https://github.com/zoff99/ToxAndroidRefImpl/blob/zoff99/dev003/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java#L1941

zoff99 commented 2 years ago

@cuixiaoyiyi can you make a PR with proposed fixes?