I am currently working on an application that runs on iOS and Android. The core of the application is written in C ++ and over time allocates more and more memory. The fact is that I want at the same time it is possible to use as much memory as possible and ensure the stability of the application.
Of course, for this I will need to know how much memory I can use. Thus, if after a while I see that I need more than is available, I can stop the allocation instead of being killed by the operating system or crashing.
The problem is that after reading and testing various solutions, my feeling is that the information you dynamically receive is not reliable enough. For example, on iOS:
[NSProcessInfo processInfo].physicalMemory
This is one of the typical examples / answers I read that seem unreliable. It seems that you cannot get enough information dynamically to make sure that you still have enough memory, because the OS will kill your application at some point if it uses too much memory and sends warnings earlier. But it can also kill other applications between them, so stopping when I get the first one seems not the optimal solution.
After reading a lot of posts, I am a little confused on this topic. Is there a way to find out dynamically and reliably how much memory is left for my iOS / Android application? Or is memory management from these OSs too unpredictable for this?
Thanks for the help!
source share