本文整理汇总了Java中android.os.Debug.getNativeHeapFreeSize方法的典型用法代码示例。如果您正苦于以下问题:Java Debug.getNativeHeapFreeSize方法的具体用法?Java Debug.getNativeHeapFreeSize怎么用?Java Debug.getNativeHeapFreeSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Debug
的用法示例。
在下文中一共展示了Debug.getNativeHeapFreeSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例3: 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)");
}
示例4: getNativeHeapFreeSize
import android.os.Debug; //导入方法依赖的package包/类
/** 未使用的 堆内存, 单位 MB */
public static long getNativeHeapFreeSize() {
return Debug.getNativeHeapFreeSize() / 1024 / 1024;
}
示例5: getNativeHeapFreeSize
import android.os.Debug; //导入方法依赖的package包/类
public static long getNativeHeapFreeSize() {
return Debug.getNativeHeapFreeSize() / DataConstants.BYTES_PER_KILOBYTE;
}