美文网首页JavaJava学习笔记Java 杂谈
Java获取heap信息heapSize, heapMaxSiz

Java获取heap信息heapSize, heapMaxSiz

作者: learningops | 来源:发表于2018-03-22 13:15 被阅读5次
    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
    }

相关文章

网友评论

    本文标题:Java获取heap信息heapSize, heapMaxSiz

    本文链接:https://www.haomeiwen.com/subject/pflaqftx.html