SecUSo / privacy-friendly-memo-game

Privacy Friendly App for playing "pairs" on Android devices.
GNU General Public License v3.0
26 stars 25 forks source link

potential memory leak of statisticsActivity variable #31

Closed yuchi1989 closed 4 years ago

yuchi1989 commented 4 years ago

Hi,

We (@yuchi1989 + @guitard0g) are researchers in Columbia University developing a static analysis tool to analyze memory leak bugs related to UI objects. Our tool identifies one bug in your source code (particularly the onCreate method of StatisticsActivity.java). Here is the code snippet.

https://github.com/SecUSo/privacy-friendly-memo-game/blob/87d0844f2db7ae79d2715825f00e44932aad7c98/app/src/main/java/org/secuso/privacyfriendlymemory/ui/navigation/StatisticsActivity.java#L60

Here we are storing an Activity in a static variable, which can lead to this Activity persisting beyond its lifecycle when the app is suspended or closed. Often you can save memory usage by setting this statisticsActivity variable to null in the onPause() or onDestroy() methods in the Activity.

hanneshofmann commented 4 years ago

Hi @yuchi1989!

Thanks for reporting. I will eventually create a PR tomorrow to proper discard the object reference as suggested in the onDestroy hook.