I've implemented application state saving/loading in onSave/RestoreInstanceState and onCreate in one of my android app's activities. Is there any way to force the emulator to remove my app from memory so that onRestoreInstanceState is called?
Currently it looks like my app just stays in memory (for a time longer than I am willing to wait anyway). When I hit the "home" button when my activity is active I get the following method calls:
When I reactivate my app, all I get is
Is there any way in the emulator to force my app to be mothballed so that onRestoreInstanceState and/or onCreate are called again?
Create a loop, that allocates objects to memory. You can just "new" up a bunch of objects in a loop, and run it that way. If you allocate enough Strings, or int objects into a single array, this will run OOM eventually (this is also a good way to gradually build to an OOM condition).
onTrimMemory. Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process. This will happen for example when it goes in the background and there is not enough memory to keep as many background processes running as desired.
It is possible. Just use the Windows API functions WriteProcessMemory/ReadProcessMemory . Pass in the handle of the process and the pointer to the data.
When inspecting your app's heap, Android computes a value called the Proportional Set Size (PSS), which accounts for both dirty and clean pages that are shared with other processes—but only in an amount that's proportional to how many apps share that RAM.
Use the DevTools app ("Immediately destroy activities").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With