JDK-8151482 : G1 uses too much physical memory for BitMap during JVM start-up
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2016-03-09
  • Updated: 2016-03-09
  • Resolved: 2016-03-09
Related Reports
Duplicate :  
Description
A simple test case:  "Wait" is a program that just sleeps at start-up

# by default, G1 is enabled in JDK9
java -cp . Wait

# choose a different GC
java -XX:+UseParallelGC -cp . Wait

Using ps_mem.py (https://github.com/pixelb/ps_mem) on Linux:

G1:  120.23 MiB +  0.26 MiB = 120.50 MiB	java
Parallel: 21.87 MiB +  0.20 MiB = 22.07 MiB	java

The 100MB of overhead comes from here:

G1ConcurrentMark::G1ConcurrentMark() {
   ...
   for (uint i = 0; i < _max_worker_id; ++i) {
     ...
    _count_card_bitmaps[i] = BitMap(card_bm_size, false);
}

This loop executes for 23 times with default JVM parameters. Each iteration allocations about 4MB of malloc memory that's zero initialized.

----> Is it possible to allocate the BitMap array using anonymous mmap so that (a) it appears as zero initialized so when you read from it you get zeros, (b) no physical memory is allocated until you write into a page? Linux mmap seems to suggest that can be done but I am not 100% sure.