In iOS an app will receive a memory warning by implementing a function called DidReceiveMemoryWarning
, which means the RAM is not enough to use. If a Level 2 version of this warning is sent, the app will probably be force stopped.
Is there something similar (like a broadcast intent) in Android to tell my app that we're out of RAM and i could remove some objects programmatically?
Thanks.
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.
The Heap is used for dynamic memory allocation. To provide a smooth user experience, Android sets a hard limit on the heap size for each running application. The heap size limit varies among devices and is based on how much RAM a device has.
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.
Overview. iOS sends your app a warning when its memory use approaches the limit of available device memory. The amount of memory use that triggers a memory warning corresponds to the yellow region in Xcode's memory gauge.
You should define your own custom application object by extending Android Application class and define that object in the Application tag in the manifest file. In this custom object you can override the onLowMemory() method.
Hope this helps you.
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