I have the following memory details from the DDMS perspective of Eclipse.
However in spite of implementing the following code, I'm unable to obtain the values shown in the above image.
private void logHeap() {
long maxMemory = Runtime.getRuntime().maxMemory()/ (1024*1024);
long totalMemory = Runtime.getRuntime().totalMemory() / (1024*1024);
long heapSize = Debug.getNativeHeapSize()/(1024*1024);
long allocatedHeapSize = Debug.getNativeHeapAllocatedSize() / (1024*1024);
long freeHeapSize = Debug.getNativeHeapFreeSize() / (1024*1024);
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
df.setMinimumFractionDigits(2);
Log.d(TAG, "debug. =================================");
Log.d(TAG,"Max memory: "+df.format(maxMemory)+" MB");
Log.d(TAG,"Total memory: "+df.format(totalMemory)+" MB");
Log.d(TAG,"Heap Size: "+df.format(heapSize)+" MB");
Log.d(TAG,"Allocated Heapsize: "+df.format(allocatedHeapSize)+" MB");
Log.d(TAG,"Free Heapsize: "+df.format(freeHeapSize)+" MB");
}
I'm getting the following values:
Max Memory : 36.00MB
Total Memory : 7.00 MB
Heap Size : 3.00 MB
allocated heapsize : 3.00 MB
free heapsize : 0.00 MB
Are there any other APIs to obtain the details?