Retained Fragments with UI and memory leaks

后端 未结 5 1384
刺人心
刺人心 2020-12-02 05:06

I\'ve read that setting .setOnRetainInstance(true) on fragments presenting UI may lead to memory leaks.

Could somebody please explain why and how this

5条回答
  •  长情又很酷
    2020-12-02 05:44

    you can overide onDestroy() and invoke garbage collector.

     @Override
    public void onDestroy() {
        super.onDestroy();
        System.gc();
        System.gc();
    }
    

提交回复
热议问题