Created
April 27, 2013 07:17
-
-
Save samma835/5472190 to your computer and use it in GitHub Desktop.
function to log the memory status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void logMemory(String callingFunction) | |
{ | |
long max = Runtime.getRuntime().maxMemory() / 1024; | |
if (debugJavaMemory) | |
{ | |
long used = Runtime.getRuntime().totalMemory() / 1024; | |
long available = max - used; | |
long change = available - availableJavaMemoryOld; | |
if (availableJavaMemoryOld != 0) | |
Log.i(TAG_MEMORY, "jMEM M:" + max + ", U:" + used + ", A:" + available + ", C:" + change + ", " + callingFunction); | |
availableJavaMemoryOld = available; | |
} | |
else if (debugNativeMemory) | |
{ | |
long used = Debug.getNativeHeapAllocatedSize() / 1024; | |
long available = max - used; | |
long change = available - availableNativeMemoryOld; | |
if (availableNativeMemoryOld != 0) | |
Log.i(TAG_MEMORY, "nMEM M:" + max + ", U:" + used + ", A:" + available + ", C:" + change + ", " + callingFunction); | |
availableNativeMemoryOld = available; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment