java memory主要分heap memory 和 non-heap memory,其計算公式以下:html
Max memory = [-Xmx] + [-XX:MaxPermSize] + number_of_threads * [-Xss]
heap結構 按分代,分young-eden,young-survivor,old 用-Xmn,-Xms,-Xmx來指定。java
non-heap結構 包括metaspace,thread stacks,compiled native code,memory allocated by native code -XX:PermSize或-XX:MetaspceSize,-Xss或-XX:ThreadStackSize。 git
J ava的內存管理涉及到以下類:ResourceObj, CHeapObj, StackObj, ValueObj, AllStatic, AllocatedObj(ALLOCATIONSUPER_CLASS_SPEC)github
((cite: hotspot/src/share/vm/memory/allocation.hpp)) // All classes in the virtual machine must be subclassed // by one of the following allocation classes: // // For objects allocated in the resource area (see resourceArea.hpp). // - ResourceObj // // For objects allocated in the C-heap (managed by: free & malloc). // - CHeapObj // // For objects allocated on the stack. // - StackObj // // For embedded objects. // - ValueObj // // For classes used as name spaces. // - AllStatic
參考文章:spa
(1)JVM Internals http://blog.jamesdbloom.com/JVMInternals.htmlcode
(2)HotSpot を構成するクラスの基底クラス, およびそれらのメモリ管理方法 http://hsmemo.github.io/articles/no28916gIW.htmlhtm