1

Due to the "out of memory" issue, is it possible to reset the HEAP via restart app?

Below is the code I found from "stackoverflow" to restart app. But from Eclipse DDMS, the Heap did not reset.

Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage( getBaseContext().getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);

Thanks...

trincot
  • 317,000
  • 35
  • 244
  • 286
andrewwang1TW
  • 119
  • 3
  • 14
  • why not releasing the objects you allocated and run gc ? – Mr.Me Feb 23 '13 at 18:08
  • Actually, it's the google map v1, just can not release it at all. I have tried the way "https://code.google.com/p/android/issues/detail?id=2181" mentioned but from DDMS, even the "MapActivty" is "onDestroy", the heap still not released. By now, I plan to kill the process and restart it again. – andrewwang1TW Feb 24 '13 at 09:56

1 Answers1

0

Due to the "out of memory" issue, is it possible to reset the HEAP via restart app?

Eventually, Android will terminate your process, after it moves to the background for a while. The new process will start with a fresh heap.

Below is the code I found from "stackoverflow" to restart app. But from Eclipse DDMS, the Heap did not reset.

That is because you are still working with the same process.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • See, then is it possible to kill process (int pid = android.os.Process.myPid(); android.os.Process.killProcess(pid);) then restart it again. Thanks. – andrewwang1TW Feb 24 '13 at 09:52
  • OK, finally I know how to do that....http://stackoverflow.com/questions/2681499/android-how-to-auto-restart-application-after-its-been-force-closed – andrewwang1TW Feb 24 '13 at 10:58