android 剩余内存,Android:如何检查剩余的内存量?
下面是我的公式來檢查剩余的內存量(不是多少內存保留在當前堆,但在應用程序崩潰之前可以利用多少內存)。我不能遠程確定這是正確的,是嗎?
double max = Runtime.getRuntime().maxMemory(); //the maximum memory the app can use
double heapSize = Runtime.getRuntime().totalMemory(); //current heap size
double heapRemaining = Runtime.getRuntime().freeMemory(); //amount available in heap
double nativeUsage = Debug.getNativeHeapAllocatedSize(); //is this right? I only want to account for native memory that my app is being "charged" for. Is this the proper way to account for that?
//heapSize - heapRemaining = heapUsed + nativeUsage = totalUsage
double remaining = max - (heapSize - heapRemaininng + nativeUsage);
總結
以上是生活随笔為你收集整理的android 剩余内存,Android:如何检查剩余的内存量?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android service使用han
- 下一篇: qq android2.0,取代QQ?腾