Skip to content
Writes to mmap-ed files on Linux can cause JVM garbage collection pauses
C Java Shell
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Pauses when writing mmap-ed files

See my blog post for details.

  1. Start a new Ubuntu image.
  2. Run the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install linux-virtual gcc screen openjdk-8-jdk
sudo reboot
  1. Copy these files to this machine.
  2. gcc --std=gnu99 -O3 -Wall -Wextra -o mmapwritepause mmapwritepause.c
  3. Start screen. In one terminal: ./mmapwritepause /tmp/mmapout
  4. In another terminal: ./
  5. Watch the output of mmapwritepause; it will print long pauses.

JVM reproduction

  1. javac
  2. java -XX:+PrintGCDetails -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -Xmx1G -Xms1G MakeGarbage
  3. In another terminal, run ./

This will show large safepoint times, correlated with when mmapwritepause reports pauses. To verify that disabling the stats fixes the problem, add -XX:+PerfDisableSharedMem and rerun it.

You can’t perform that action at this time.