java memory主要分heap memory 和 non-heap memory,其计算公式如下:
Max memory = [-Xmx] + [-XX:MaxPermSize] + number_of_threads * [-Xss]
heap结构 按分代,分young-eden,young-survivor,old 用-Xmn,-Xms,-Xmx来指定。
non-heap结构 包括metaspace,thread stacks,compiled native code,memory allocated by native code -XX:PermSize或-XX:MetaspceSize,-Xss或-XX:ThreadStackSize。
J ava的内存管理涉及到如下类:ResourceObj, CHeapObj, StackObj, ValueObj, AllStatic, AllocatedObj(ALLOCATIONSUPER_CLASS_SPEC)
((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
参考文章:
(1)JVM Internals http://blog.jamesdbloom.com/JVMInternals.html
(2)HotSpot を構成するクラスの基底クラス, およびそれらのメモリ管理方法 http://hsmemo.github.io/articles/no28916gIW.html