Java Memory : Runtime.getRuntime().maxMemory()

孤街醉人 提交于 2019-12-20 03:25:10

问题


Runtime.getRuntime().maxMemory() 

shows which memory ? Is it Survivor , Eden , Old, Permanent ?


回答1:


It is the maximum size of the heap. It is loosely based on the -mx or -Xmx command line argument but for reasons I don't understand can be 1-5% less (It doesn't seem to be ever exactly the same)

What this doesn't include is the perm gen, the direct memory, memory mapped files, stack spaces or shared libraries.

While it doesn't include everything is it usually 80-90% the total memory usable for most applications.




回答2:


According to API, Returns the maximum amount of memory that the Java virtual machine will attempt to use. If there is no inherent limit then the value Long.MAX_VALUE will be returned.



来源:https://stackoverflow.com/questions/13988328/java-memory-runtime-getruntime-maxmemory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!