Example usage for android.os Debug getNativeHeapAllocatedSize

List of usage examples for android.os Debug getNativeHeapAllocatedSize

Introduction

In this page you can find the example usage for android.os Debug getNativeHeapAllocatedSize.

Prototype

public static native long getNativeHeapAllocatedSize();

Source Link

Document

Returns the amount of allocated memory in the native heap.

Usage

From source file:com.zoffcc.applications.zanavi.Navit.java

private static long calcAvailableMemory() {
    try {/* www .ja v a 2 s  .  co m*/
        long value = Runtime.getRuntime().maxMemory();
        String type = "";
        if (android.os.Build.VERSION.SDK_INT >= 11) {
            value = (value / 1024 / 1024) - (Runtime.getRuntime().totalMemory() / 1024 / 1024);
            type = "JAVA";
        } else {
            value = (value / 1024 / 1024) - (Debug.getNativeHeapAllocatedSize() / 1024 / 1024);
            type = "NATIVE";
        }
        Log.i("Navit", "avail.mem size=" + value + "MB, type=" + type);
        return value;
    } catch (Exception e) {
        return 0L;
    }
}