JAVA 进程使用物理内存超过预期(JDK8+G1)?

由于字数限制,以下作为补充:打开 native memory tracking 功能:Total: reserved=123984870KB, committed=123546182KB- Java Heap (reserved=111149056KB, committed=111149056KB) (mmap: reserved=111149056KB, committed=111149056KB) - Class (reserved=41742KB, committed=40426KB) (classes #5637) (malloc=782KB #10888) (mmap: reserved=40960KB, committed=39644KB) - Thread (reserved=386800KB, committed=386800KB) (thread #376) (stack: reserved=385500KB, committed=385500KB) (malloc=477KB #1903) (arena=823KB #750)- Code (reserved=254976KB, committed=34692KB) (malloc=5376KB #8553) (mmap: reserved=249600KB, committed=29316KB) - GC (reserved=4669338KB, committed=4669338KB) (malloc=511898KB #957771) (mmap: reserved=4157440KB, committed=4157440KB) - Compiler (reserved=404KB, committed=404KB) (malloc=274KB #416) (arena=131KB #3)- Internal (reserved=7226182KB, committed=7226182KB) (malloc=7226150KB #855995) (mmap: reserved=32KB, committed=32KB) - Symbol (reserved=9063KB, committed=9063KB) (malloc=7265KB #65080) (arena=1798KB #1)- Native Memory Tracking (reserved=29993KB, committed=29993KB) (malloc=229KB #3465) (tracking overhead=29764KB)- Arena Chunk (reserved=227KB, committed=227KB) (malloc=227KB) - Unknown (reserved=217088KB, committed=0KB) (mmap: reserved=217088KB, committed=0KB) 可以看到 GC 和 Internal 各自占用4G和7G, 不在JMX 中 non-heap memory 和 buffer pool之列.在将MALLOC_ARENA_MAX=4设置成MALLOC_ARENA_MAX=1后,Internal 接近3G(-4G),- Internal (reserved=3039556KB, committed=3039556KB) (malloc=3039524KB #330390) (mmap: reserved=32KB, committed=32KB) 打印 detail 信息,其中 G1 申请了两块1.65G 左右的内存: reserved 1736704KB for GC from ReservedSpace::initialize(unsigned long, unsigned long, bool, char*, unsigned long, bool)+0x256 ReservedSpace::ReservedSpace(unsigned long, unsigned long)+0x6a G1CollectedHeap::initialize()+0x4f5 Universe::initialize_heap()+0xf3 committed 1736704KB from G1PageBasedVirtualSpace::commit_internal(unsigned long, unsigned long)+0xbf G1PageBasedVirtualSpace::commit(unsigned long, unsigned long)+0x11c G1RegionsLargerThanCommitSizeMapper::commit_regions(unsigned int, unsigned long)+0x40 HeapRegionManager::commit_regions(unsigned int, unsigned long)+0x97 reserved 1736704KB for GC from ReservedSpace::initialize(unsigned long, unsigned long, bool, char*, unsigned long, bool)+0x256 ReservedSpace::ReservedSpace(unsigned long, unsigned long)+0x6a G1CollectedHeap::initialize()+0x475 Universe::initialize_heap()+0xf3 committed 1736704KB from G1PageBasedVirtualSpace::commit_internal(unsigned long, unsigned long)+0xbf G1PageBasedVirtualSpace::commit(unsigned long, unsigned long)+0x11c G1RegionsLargerThanCommitSizeMapper::commit_regions(unsigned int, unsigned long)+0x40 HeapRegionManager::commit_regions(unsigned int, unsigned long)+0x87------------------ ReservedSpace::initialize(unsigned long, unsigned long, bool, char*, unsigned long, bool)+0x256 ReservedSpace::ReservedSpace(unsigned long, unsigned long)+0x6a G1CollectedHeap::initialize()+0x475 Universe::initialize_heap()+0xf3 (reserved=1736704KB, committed=1736704KB) ReservedSpace::initialize(unsigned long, unsigned long, bool, char*, unsigned long, bool)+0x256 ReservedSpace::ReservedSpace(unsigned long, unsigned long)+0x6a G1CollectedHeap::initialize()+0x4f5 Universe::initialize_heap()+0xf3 (reserved=1736704KB, committed=1736704KB)


    推荐阅读