The heap is the area in memory in which objects are created.
// Get current size of heap in bytes
long heapSize = Runtime.getRuntime().totalMemory();
// Get maximum size of heap in bytes. The heap cannot grow beyond this size.
// Any attempt will result in an OutOfMemoryException.
long heapMaxSize = Runtime.getRuntime().maxMemory();
// Get amount of free memory within the heap in bytes. This size will increase
// after garbage collection and decrease as new objects are created.
long heapFreeSize = Runtime.getRuntime().freeMemory();
分享到:
相关推荐
- 分析 Retained Size:关注对象的 retained size 而非 shallow size,因为 retained size 才真正反映了对象释放后能回收的内存。 - 理解 dominator tree:利用 dominator tree 分析内存结构,找出内存消耗的主要...
The Table of Contents Each bullet shown below represents a chapter. Use the search field in the nav bar to search all of the CommonsWare books to see what they hold! Key Android Concepts Choosing ...
The Android platform gives developers a fair bit of control while still supporting a familiar programming language. However, the frameworks, GUI widgets, and development model is different than any ...
PEP 486: Make the Python Launcher aware of virtual environments PEP 488: Elimination of PYO files PEP 489: Multi-phase extension module initialization Other Language Changes New Modules typing ...
Getting In and Out of GDB . . . . . . . . . . . . . . . 11 2.1 Invoking GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Choosing files . . . . . . . . . . ....