We have an Android hardware/software combo that we install at client sites.
On certain tablets, the memory starts running low, and Android starts doing its thing by killing our app, which is then automatically restarted by our watchdog service.
Here is the code we use to monitor per-app memory usage
:
for( RunningAppProcessInfo info : am.getRunningAppProcesses() ) {
int memused = am.getProcessMemoryInfo(
new int[]{info.pid})[0].getTotalPss();
Log.log(DIAG_INFO, "Process Mem: " + info.processName, memused);
}
Here is the code that gets us overall system memory levels
MemoryInfo mi = new MemoryInfo();
am.getMemoryInfo(mi);
long availableMegs = mi.availMem / 1048576L;
long threshold = mi.threshold /1048576L;
availableMegs
drops to near the threshold
(64mb in our case) and android starts killing stuff.
But, when we look at the per-process memory usage, add up the TotalPss
values, we get a normal total. No process that is out of control memory-wise!
Any ideas where the missing RAM has gone?