jvm - 内存结构以其解析
可以将jvm粗略分为以下部分:
- Heap Memory:存储java对象.
- Non-Heap Memory:存储加载的class文件,以及其他meta-data信息.
- Other:存储java代码,jvm内部结构等.
Heap Memory:
是在jvm启动的时候分配的
-Xmx<size>:设置堆的最大大小.
-Xms<size>:设置初始的对大小.
默认情况下,堆的最大大小是64MB,堆是否是固定大小,可扩展都是有gc策略决定的.
可以通过:-XX:MaxPermSize
设置堆的大小,如:-XX:MaxPermSize=128m.
可以在"Memory'下查看heap和non-heap的信息:
Used Heap Memory: Live and Dead Objects
Used heap memory consists of live and dead objects.
Live objects are accessible by the application and will not be a subject of garbage collection.
Dead objects are those which will never be accessible by the application but have not been collected yet by the garbage collector.
Class list同时显示live and dead objects,可以通过查看gc发生时对象的数量变化来分析情况.