当前位置: 首页>>代码示例>>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;未经允许,请勿转载。