Java Runtime.maxMemory incorrect?

后端 未结 4 1873
北荒
北荒 2020-12-07 00:02

I ran the following method Runtime.getRuntime().maxMemory() and gave 85196800.

However, I then ran top from the command line and it showed

  PID U         


        
4条回答
  •  误落风尘
    2020-12-07 00:30

    Runtime.getRuntime().maxMemory() is returning an estimate of the maximum heap size, not the total amount of memory that will be consumed by the entire process. Native memory, native libraries, etc. will contribute to the process size but not to maxMemory().

提交回复
热议问题