java查看 被应用_java – 如何查看应用程序正在使用的当前堆大小?
生活随笔
收集整理的這篇文章主要介紹了
java查看 被应用_java – 如何查看应用程序正在使用的当前堆大小?
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
使用此代碼:
// 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();
它是有用的,我知道它。
總結(jié)
以上是生活随笔為你收集整理的java查看 被应用_java – 如何查看应用程序正在使用的当前堆大小?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux brctl命令,Linux中
- 下一篇: 隔一段时间查找一次 golang_剑指