Reputation: 701
In my application i override the onLowmemory method. It gets called every time. And my mobile is stuck. How to release memory in this method.
I am using below code :
@Override
public void onLowMemory() {
// TODO Auto-generated method stub
super.onLowMemory();
System.out.println("*************************************************");
System.out.println("********** on low memory ************************");
System.out.println("*************************************************");
System.gc();
}
Only using system.gc ... thank you.
Upvotes: 0
Views: 1261
Reputation: 683
I don't know what's going on, but my application stopped killing lowMemoryKiller when I added this code:
@Override
public void onLowMemory() {
super.onLowMemory();
Runtime.getRuntime().gc();
}
Upvotes: 0
Reputation: 1122
You should never call System.gc() it creates performance issues. You have to free references to any heavy objects you are holding - Look at the footprint of your application. Take a heap dump and see it in MAT. Look at what objects are taking most memory and check if you can free them.
Upvotes: 1