Android: how to check how much memory is remaining?

Try the following code. that should give you the results you are after (especially the Pss field). You can read more about it here

Debug.MemoryInfo memoryInfo = new Debug.MemoryInfo();
Debug.getMemoryInfo(memoryInfo);

String memMessage = String.format(
    "Memory: Pss=%.2f MB, Private=%.2f MB, Shared=%.2f MB",
    memoryInfo.getTotalPss() / 1024.0,
    memoryInfo.getTotalPrivateDirty() / 1024.0,
    memoryInfo.getTotalSharedDirty() / 1024.0);

Leave a Comment