Java JMX MemoryManagerMXBean
JMX Java About 1,620 words功能
MemoryManagerMXBean
可以获取Java
服务的内存管理器信息:
CodeCacheManager
: 代码缓存管理器Metaspace Manager
: 元数据管理器G1 Young Generation
:G1
年轻代G1 Old Generation
:G1
老年代
代码
public class MemoryManagerMXBeansTest {
public static void main(String[] args) {
List<MemoryManagerMXBean> memoryManagerMXBeans = ManagementFactory.getMemoryManagerMXBeans();
for (MemoryManagerMXBean memoryManagerMXBean : memoryManagerMXBeans) {
System.out.println("name: " + memoryManagerMXBean.getName());
System.out.println("isValid: " + memoryManagerMXBean.isValid());
System.out.println("objectName: " + memoryManagerMXBean.getObjectName());
System.out.println("memoryPoolNames: " + Arrays.toString(memoryManagerMXBean.getMemoryPoolNames()));
System.out.println("----------------");
}
}
}
输出
name: CodeCacheManager
isValid: true
objectName: java.lang:type=MemoryManager,name=CodeCacheManager
memoryPoolNames: [CodeHeap 'non-nmethods', CodeHeap 'profiled nmethods', CodeHeap 'non-profiled nmethods']
----------------
name: Metaspace Manager
isValid: true
objectName: java.lang:type=MemoryManager,name=Metaspace Manager
memoryPoolNames: [Metaspace, Compressed Class Space]
----------------
name: G1 Young Generation
isValid: true
objectName: java.lang:type=GarbageCollector,name=G1 Young Generation
memoryPoolNames: [G1 Eden Space, G1 Survivor Space, G1 Old Gen]
----------------
name: G1 Old Generation
isValid: true
objectName: java.lang:type=GarbageCollector,name=G1 Old Generation
memoryPoolNames: [G1 Eden Space, G1 Survivor Space, G1 Old Gen]
----------------
Views: 659 · Posted: 2024-01-05
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...