get Java Heap Size - Android Hardware

Android examples for Hardware:Memory

Description

get Java Heap Size

Demo Code


//package com.java2s;

import android.os.Build;
import android.os.Debug;

public class Main {

    public static long getJavaHeapSize() {
        if (Build.VERSION.SDK_INT >= 9) {
            return Runtime.getRuntime().totalMemory();
        } else {/*from w  ww  .jav  a2 s. c  o m*/
            return Runtime.getRuntime().totalMemory()
                    + Debug.getNativeHeapAllocatedSize();
        }
    }
}

Related Tutorials