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


Java Debug.getNativeHeapAllocatedSize方法代碼示例

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


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

示例1: getBitmapMemoryUsage

import android.os.Debug; //導入方法依賴的package包/類
public static double getBitmapMemoryUsage() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            return getMemoryUsage();
        }

        long max = Runtime.getRuntime().maxMemory();
        long used = Debug.getNativeHeapAllocatedSize();

        return (double) used / (double) max;
    }
 
開發者ID:ceji-longquan,項目名稱:ceji_android,代碼行數:12,代碼來源:Configuration.java

示例2: nativePrintMemory

import android.os.Debug; //導入方法依賴的package包/類
/**
 * 打印native內存占用情況
 * 
 * @param info 相關信息
 */
public static void nativePrintMemory(String info) {
    if (  !DEBUG_MEMORY) {
        return;
    }
    long totalNativeMemory = Debug.getNativeHeapAllocatedSize();
    long freeNativeMemory = Debug.getNativeHeapFreeSize();
    long nativeMemory = Debug.getNativeHeapSize();
    String content =
        info + "-->totalNativeMemory:" + (totalNativeMemory >> 10) + ",freeNativeMemory:" + (freeNativeMemory >> 10) + ",nativeMemory:" + (nativeMemory >> 10) + "\n";
    Log.d(
        content);
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:18,代碼來源:MemoryLog.java

示例3: showMemoryStats

import android.os.Debug; //導入方法依賴的package包/類
public static void showMemoryStats(String message) {
    Log.i("memory", message
            + "----------------------------------------------------------------------------------------");
    double nativeUsage = Debug.getNativeHeapAllocatedSize();
    Log.i("memory", "nativeUsage: " + (nativeUsage / 1048576d));
    // current heap size
    double heapSize = Runtime.getRuntime().totalMemory();
    // Log.i("memory", "heapSize: " + (heapSize / 1048576d));
    // amount available in heap
    double heapRemaining = Runtime.getRuntime().freeMemory();
    // Log.i("memory", "heapRemaining: " + (heapRemaining / 1048576d));
    double memoryAvailable = Runtime.getRuntime().maxMemory() - (heapSize - heapRemaining) - nativeUsage;
    Log.i("memory", "memoryAvailable: " + (memoryAvailable / 1048576d));

    if (first) {
        initavail = memoryAvailable;
        first = false;
    }
    if (lastavail > 0) {
        Log.i("memory", "consumed since last: " + ((lastavail - memoryAvailable) / 1048576d));
    }
    Log.i("memory", "consumed total: " + ((initavail - memoryAvailable) / 1048576d));

    lastavail = memoryAvailable;

    Log.i("memory",
            "-----------------------------------------------------------------------------------------------");
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:29,代碼來源:MemoryLogger.java

示例4: getFreeMemorySize

import android.os.Debug; //導入方法依賴的package包/類
public static long getFreeMemorySize() {
    long max = Runtime.getRuntime().maxMemory();
    long heapSize = Runtime.getRuntime().totalMemory();
    long heapRemaining = Runtime.getRuntime().freeMemory();
    long nativeUsage = Debug.getNativeHeapAllocatedSize();
    return (max - heapSize - nativeUsage) + heapRemaining;
}
 
開發者ID:markzhai,項目名稱:AndroidProjectFrom0,代碼行數:8,代碼來源:ImageScaleUtil.java

示例5: detectDebugPreference

import android.os.Debug; //導入方法依賴的package包/類
private void detectDebugPreference() {
	Preference debugPreferenceCategory = (PreferenceCategory) findPreference(DEBUG_INFO);
	Preference debugPreference = findPreference(SettingActivity.DEBUG_MEM_INFO);
	Preference crashPreferenceCategory = findPreference(SettingActivity.CRASH);

	if (SettingUtils.isBlackMagicEnabled()) {

		Runtime rt = Runtime.getRuntime();
		long vmAlloc = rt.totalMemory() - rt.freeMemory();
		long nativeAlloc = Debug.getNativeHeapAllocatedSize();

		String vmAllocStr = "VM Allocated " + formatMemoryText(vmAlloc);
		String nativeAllocStr = "Native Allocated " + formatMemoryText(nativeAlloc);

		ActivityManager am = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
		int memoryClass = am.getMemoryClass();
		String result = "VM Max " + Integer.toString(memoryClass) + "MB";
		debugPreference.setSummary(vmAllocStr + "," + nativeAllocStr + "," + result);

		crashPreferenceCategory.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
			@Override
			public boolean onPreferenceClick(Preference preference) {
				throw new IllegalArgumentException("about -> crash test");
			}
		});
	} else {
		PreferenceScreen screen = getPreferenceScreen();
		screen.removePreference(debugPreferenceCategory);
	}
}
 
開發者ID:lookwhatlook,項目名稱:WeiboWeiBaTong,代碼行數:31,代碼來源:AboutFragment.java

示例6: logHeap

import android.os.Debug; //導入方法依賴的package包/類
public static void logHeap() {
    Double allocated = new Double(Debug.getNativeHeapAllocatedSize())/new Double((1048576));
    Double available = new Double(Debug.getNativeHeapSize())/1048576.0;
    Double free = new Double(Debug.getNativeHeapFreeSize())/1048576.0;
    DecimalFormat df = new DecimalFormat();
    df.setMaximumFractionDigits(2);
    df.setMinimumFractionDigits(2);

    Log.d("tag", "debug. =================================");
    Log.d("tag", "debug.heap native: allocated " + df.format(allocated) + "MB of " + df.format(available) + "MB (" + df.format(free) + "MB free)");
    Log.d("tag", "debug.memory: allocated: " + df.format(new Double(Runtime.getRuntime().totalMemory()/1048576)) + "MB of " + df.format(new Double(Runtime.getRuntime().maxMemory()/1048576))+ "MB (" + df.format(new Double(Runtime.getRuntime().freeMemory()/1048576)) +"MB free)");
}
 
開發者ID:buithuyet,項目名稱:BeautyCamera,代碼行數:13,代碼來源:ImgView.java

示例7: checkBitmapFitsInMemory

import android.os.Debug; //導入方法依賴的package包/類
/**
 * Checks if a bitmap with the specified size fits in memory
 * Source: https://stackoverflow.com/a/6893818
 *
 * @param bmpwidth   Bitmap width
 * @param bmpheight  Bitmap height
 * @param bmpdensity Bitmap bpp (use 2 as default)
 * @return true if the bitmap fits in memory false otherwise
 */
private static boolean checkBitmapFitsInMemory(long bmpwidth, long bmpheight, int bmpdensity) {
    long reqsize = bmpwidth * bmpheight * bmpdensity;
    long allocNativeHeap = Debug.getNativeHeapAllocatedSize();

    final long heapPad = (long) Math.max(4 * 1024 * 1024, Runtime.getRuntime().maxMemory() * 0.1);
    if ((reqsize + allocNativeHeap + heapPad) >= Runtime.getRuntime().maxMemory()) {
        return false;
    }
    return true;
}
 
開發者ID:konir,項目名稱:RadioRecPlus,代碼行數:20,代碼來源:Images.java

示例8: getHeapNative

import android.os.Debug; //導入方法依賴的package包/類
public static long[] getHeapNative() {
	long[] value = new long[2];
	value[0] = Debug.getNativeHeapSize() >> 10;
	value[1] = Debug.getNativeHeapAllocatedSize() >> 10;
	return value;
}
 
開發者ID:r551,項目名稱:GTTools,代碼行數:7,代碼來源:MEMUtils.java

示例9: getNativeHeapAllocatedSize

import android.os.Debug; //導入方法依賴的package包/類
/** 已獲得 堆內存, 單位 MB */
public static long getNativeHeapAllocatedSize() {
	return Debug.getNativeHeapAllocatedSize() / 1024 / 1024;
}
 
開發者ID:imknown,項目名稱:IMKBaseFrameworkLibrary,代碼行數:5,代碼來源:DeviceUtil.java

示例10: getNativeHeap

import android.os.Debug; //導入方法依賴的package包/類
@Override
public long getNativeHeap () {
   return Debug.getNativeHeapAllocatedSize();
}
 
開發者ID:raphaelbruno,項目名稱:ZombieInvadersVR,代碼行數:5,代碼來源:CardBoardAndroidApplication.java

示例11: getNativeHeap

import android.os.Debug; //導入方法依賴的package包/類
@Override
public long getNativeHeap() {
    return Debug.getNativeHeapAllocatedSize();
}
 
開發者ID:SiliconLabs,項目名稱:thunderboard-android,代碼行數:5,代碼來源:GdxDemoActivity.java

示例12: getNativeHeapAllocatedSize

import android.os.Debug; //導入方法依賴的package包/類
public static long getNativeHeapAllocatedSize() {
	return Debug.getNativeHeapAllocatedSize() / DataConstants.BYTES_PER_KILOBYTE;
}
 
開發者ID:ArturVasilov,項目名稱:AndroidCourses,代碼行數:4,代碼來源:SystemUtils.java


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