當前位置: 首頁>>代碼示例>>Java>>正文


Java Debug.getMemoryInfo方法代碼示例

本文整理匯總了Java中android.os.Debug.getMemoryInfo方法的典型用法代碼示例。如果您正苦於以下問題:Java Debug.getMemoryInfo方法的具體用法?Java Debug.getMemoryInfo怎麽用?Java Debug.getMemoryInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.Debug的用法示例。


在下文中一共展示了Debug.getMemoryInfo方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: MemoryResource

import android.os.Debug; //導入方法依賴的package包/類
public MemoryResource() {
    memoryInfoList.clear();

    memoryInfoList.add(Runtime.getRuntime().maxMemory());
    memoryInfoList.add(Runtime.getRuntime().totalMemory());
    memoryInfoList.add(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
    memoryInfoList.add(Runtime.getRuntime().freeMemory());

    this.natHeapSize = Debug.getNativeHeapSize();
    this.natHeapFreeSize = Debug.getNativeHeapFreeSize();
    this.pss = Debug.getPss();
    this.loadedClassCount = Debug.getLoadedClassCount();

    this.memoryInfo = new Debug.MemoryInfo();
    Debug.getMemoryInfo(memoryInfo);
}
 
開發者ID:TeamThresh,項目名稱:Lantern-sdk,代碼行數:17,代碼來源:MemoryResource.java

示例2: printMemoryStatus

import android.os.Debug; //導入方法依賴的package包/類
/**
 * 打印當前內存占用日誌,方便外界診斷。注意,這會顯著消耗性能(約50ms左右)
 *
 * @param tag Used to identify the source of a log message.  It usually identifies
 *            the class or activity where the log call occurs.
 * @param msg The message you would like logged.
 */
public static int printMemoryStatus(String tag, String msg) {
    if (RePluginInternal.FOR_DEV) {
        Debug.MemoryInfo mi = new Debug.MemoryInfo();
        Debug.getMemoryInfo(mi);

        String mit = "desc=, memory_v_0_0_1, process=, " + IPC.getCurrentProcessName() +
                ", totalPss=, " + mi.getTotalPss() +
                ", dalvikPss=, " + mi.dalvikPss +
                ", nativeSize=, " + mi.nativePss +
                ", otherPss=, " + mi.otherPss + ", ";

        return Log.i(tag + "-MEMORY", mit + msg);
    }
    return -1;
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:23,代碼來源:LogDebug.java

示例3: run

import android.os.Debug; //導入方法依賴的package包/類
@Override
public void run() {
    while(mRunning) {
        mCpuStats.parseTopResults();

        Debug.getMemoryInfo(mi);

        if(mHandler != null) {
            mQosObject.cpuUsage = mCpuStats.getProcessCpuUsage();
            mQosObject.pss = mi.getTotalPss();
            mQosObject.vss = mi.getTotalPrivateDirty();
            mHandler.obtainMessage(VideoPlayerActivity.UPDATE_QOSMESS, mQosObject).sendToTarget();
        }
        try {
            sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:ksvc,項目名稱:ksyhttpcache_android,代碼行數:21,代碼來源:QosThread.java

示例4: printDeviceInformation

import android.os.Debug; //導入方法依賴的package包/類
public static void printDeviceInformation(Context ctx, PrintWriter out) {
	out.println();
	out.println("Memory Information --------");
	MemoryInfo mem = new MemoryInfo();
	Debug.getMemoryInfo(mem);
	out.println("TotalPss: " + mem.getTotalPss() + "KB");
	out.println("TotalPrivateDirty: " + mem.getTotalPrivateDirty() + "KB");
	out.println("TotalSharedDirty: " + mem.getTotalSharedDirty() + "KB");
	out.println("HeapAllocatedSize: " + Debug.getNativeHeapAllocatedSize() / 1024 + "KB");
	out.println("HeapSize: " + Debug.getNativeHeapSize() / 1024 + "KB");

	out.println();
	out.println("Device Information ---------");
	out.println("manufactor: " + Build.MANUFACTURER);
	out.println("model: " + Build.MODEL);
	out.println("version: " + Build.VERSION.RELEASE);
	out.println("product: " + Build.PRODUCT);
	out.println("hardware: " + Build.HARDWARE);
	out.println("board: " + Build.BOARD);
	out.println("device: " + Build.DEVICE);
	out.println("CPU_ABI: " + Build.CPU_ABI);
	out.println("CPU_ABI2: " + Build.CPU_ABI2);

	out.println();
	out.println("Display Information --------");
	DisplayMetrics dm = ctx.getResources().getDisplayMetrics();
	out.println("Width: " + dm.widthPixels);
	out.println("Height: " + dm.heightPixels);
	out.println("Density: " + dm.density);
	out.println("DPI: " + dm.densityDpi);
	out.println("ScaledDensity: " + dm.scaledDensity);

}
 
開發者ID:ROKOLabs,項目名稱:ROKO.Stickers-Android,代碼行數:34,代碼來源:CrashMonitor.java

示例5: memoryOK

import android.os.Debug; //導入方法依賴的package包/類
private boolean memoryOK() {
    ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
    ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    activityManager.getMemoryInfo(mi);

    Debug.MemoryInfo md = new Debug.MemoryInfo();
    Debug.getMemoryInfo(md);
    Runtime rt = Runtime.getRuntime();
    long used_memory = md.getTotalPss() / 1024;
    long max_memory = rt.maxMemory() / (1024 * 1024);
    return true;
    //return (max_memory - used_memory) > MEMORY_LIMIT;
}
 
開發者ID:bbodin,項目名稱:slambench-android,代碼行數:14,代碼來源:BenchmarkActivity.java

示例6: getMemoryInfo

import android.os.Debug; //導入方法依賴的package包/類
public static MemoryInfo getMemoryInfo() {
	/* Lazy allocation. */
	if (SystemUtils.sMemoryInfo == null) {
		SystemUtils.sMemoryInfo = new MemoryInfo();
	}

	Debug.getMemoryInfo(SystemUtils.sMemoryInfo);

	return SystemUtils.sMemoryInfo;
}
 
開發者ID:ArturVasilov,項目名稱:AndroidCourses,代碼行數:11,代碼來源:SystemUtils.java

示例7: getMemoryInfo

import android.os.Debug; //導入方法依賴的package包/類
public static void getMemoryInfo(Debug.MemoryInfo mi) {
	Debug.getMemoryInfo(mi);
}
 
開發者ID:imknown,項目名稱:IMKBaseFrameworkLibrary,代碼行數:4,代碼來源:DeviceUtil.java

示例8: a

import android.os.Debug; //導入方法依賴的package包/類
public static rgv a()
{
  Debug.MemoryInfo localMemoryInfo = new Debug.MemoryInfo();
  Debug.getMemoryInfo(localMemoryInfo);
  return a(localMemoryInfo);
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:7,代碼來源:gec.java

示例9: Allocated

import android.os.Debug; //導入方法依賴的package包/類
/**
 * 
 * @return - The amount of memory in MB that is currently allocated to this app.
 */
public static double Allocated() {				
	Debug.MemoryInfo memInfo = new Debug.MemoryInfo();
	Debug.getMemoryInfo(memInfo);
	return new Double(memInfo.getTotalPss()/1024/1024);
}
 
開發者ID:roadlabs,項目名稱:alternate-java-bridge-library,代碼行數:10,代碼來源:MemUtil.java

示例10: Free

import android.os.Debug; //導入方法依賴的package包/類
/**
 * 
 * @return - The amount of free memory left in this heap (in MB)
 */
public static double Free() {		
	Debug.MemoryInfo memInfo = new Debug.MemoryInfo();
	Debug.getMemoryInfo(memInfo);
	return new Double((Runtime.getRuntime().maxMemory() - memInfo.getTotalPss())/1024/1024);
}
 
開發者ID:roadlabs,項目名稱:alternate-java-bridge-library,代碼行數:10,代碼來源:MemUtil.java

示例11: getNativeMemoryInfo

import android.os.Debug; //導入方法依賴的package包/類
public static int getNativeMemoryInfo() {
    Debug.MemoryInfo memoryInfo = new Debug.MemoryInfo();
    Debug.getMemoryInfo(memoryInfo);


    return memoryInfo.nativePss;
}
 
開發者ID:FacePlusPlus,項目名稱:MegviiFacepp-Android-SDK,代碼行數:8,代碼來源:UiTest.java

示例12: printAvailableMemory

import android.os.Debug; //導入方法依賴的package包/類
private void printAvailableMemory() {


        ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
        ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        activityManager.getMemoryInfo(mi);

        Debug.MemoryInfo md = new Debug.MemoryInfo();
        Debug.getMemoryInfo(md);

        Runtime rt = Runtime.getRuntime();

        long availableMegs = mi.availMem / 1048576L;

        long used_memory = md.getTotalPss() / 1024;
        long max_memory = rt.maxMemory() / (1024 * 1024);

        MessageLog.addInfo("Used memory:" + Long.toString(used_memory) + "Mo" + " max app memory:" + Long.toString(max_memory) + "Mo" + " available memory:" + Long.toString(availableMegs) + "Mo");

        MessageLog.addDebug(
                " dalvikPss:" + Long.toString(md.dalvikPss) + "Ko" +
                        " nativePss:" + Long.toString(md.nativePss) + "Ko" +
                        " otherPss:" + Long.toString(md.otherPss) + "Ko"
        );

        MessageLog.addDebug(
                " NativeHeapAllocatedSize:" + Debug.getNativeHeapAllocatedSize() / 1048576L + "Mo" +
                        " NativeHeapSize:" + Debug.getNativeHeapSize() / 1048576L + "Mo");

    }
 
開發者ID:bbodin,項目名稱:slambench-android,代碼行數:31,代碼來源:LiveActivity.java


注:本文中的android.os.Debug.getMemoryInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。