JavaJava学习笔记Java 杂谈

Java获取heap信息heapSize, heapMaxSiz

2018-03-22  本文已影响5人  learningops
    public static void main(String[] args) {
        long heapSize = Runtime.getRuntime().totalMemory();
        System.out.println(readableFileSize(heapSize)); //245.5 MB
        long heapMaxSize = Runtime.getRuntime().maxMemory();
        System.out.println(readableFileSize(heapMaxSize)); //3.6 GB
        long heapFreeSize = Runtime.getRuntime().freeMemory();
        System.out.println(readableFileSize(heapFreeSize)); //239.1 MB
    }
上一篇下一篇

猜你喜欢

热点阅读