dump Memory Info - Android Hardware

Android examples for Hardware:Memory

Description

dump Memory Info

Demo Code


//package com.java2s;
import android.app.ActivityManager;

import android.content.Context;

import android.os.Debug;
import android.util.Log;

public class Main {
    static String DEBUG_CONTEXT = "ADLDebugUtils";

    static void dumpMemoryInfo(Context paramContext) {
        ActivityManager localActivityManager = (ActivityManager) paramContext
                .getSystemService("activity");
        ActivityManager.MemoryInfo localMemoryInfo = new ActivityManager.MemoryInfo();
        localActivityManager.getMemoryInfo(localMemoryInfo);
        logd(" memoryInfo.availMem " + localMemoryInfo.availMem);
        logd(" memoryInfo.lowMemory " + localMemoryInfo.lowMemory);
        logd(" memoryInfo.threshold " + localMemoryInfo.threshold);
        logd(" Debug.getNativeHeapAllocatedSize "
                + Debug.getNativeHeapAllocatedSize());
        logd(" Debug.getNativeHeapFreeSize "
                + Debug.getNativeHeapFreeSize());
    }//w ww  . j  a  v  a2  s.c o m

    static void logd(String paramString) {
        Log.d(DEBUG_CONTEXT, paramString);
    }
}

Related Tutorials