performance - Possible to free Context from Singleton in Android to prevent memory leak -


i'm maintaining legacy project can't refactoring due limitations. found possible memory leak in below scenario.

pass fragment singleton class

foo.getinstance().setbar(fragment); 

assuming static instance lives longer need it, approach null in ondestroy() method in fragment.

@override public void ondestroy(){     foo.getinstance().setbar(null);//to prevent memory leak     super.ondestroy(); } 

i'm new memory leak area, correct me if there wrong :)

use weakreference in singleton


Comments

Popular posts from this blog

php - Wordpress: Link a post to posts of another category manually -

delphi xe7 upload/download dropbox file using the rest client and show progress -

java - Get more than One value and display it -