本文整理汇总了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);
}
示例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;
}
示例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();
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例7: getMemoryInfo
import android.os.Debug; //导入方法依赖的package包/类
public static void getMemoryInfo(Debug.MemoryInfo mi) {
Debug.getMemoryInfo(mi);
}
示例8: a
import android.os.Debug; //导入方法依赖的package包/类
public static rgv a()
{
Debug.MemoryInfo localMemoryInfo = new Debug.MemoryInfo();
Debug.getMemoryInfo(localMemoryInfo);
return a(localMemoryInfo);
}
示例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);
}
示例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);
}
示例11: getNativeMemoryInfo
import android.os.Debug; //导入方法依赖的package包/类
public static int getNativeMemoryInfo() {
Debug.MemoryInfo memoryInfo = new Debug.MemoryInfo();
Debug.getMemoryInfo(memoryInfo);
return memoryInfo.nativePss;
}
示例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");
}