Release Memory of Particular Activity when it is Destroyed

前端 未结 7 1568
说谎
说谎 2020-12-15 05:38

I have a launcher Activity that load and resize big bitmap as it\'s background when it opens.

Whenever hit the back button, the Activity is

7条回答
  •  春和景丽
    2020-12-15 06:10

    even after destroying the activity by calling finish(), it's resources are queued for garbage collection. activity will be freed during next GC cycle.

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

    You can also use android:largeHeap="true" to request a larger heap size, in your application tag in manifest.

提交回复
热议问题