Windows Subsystem for Linux: shared memory not actually using RAM

While /dev/shm/ and /run/shm/ are present in Windows Subsystem for Linux (WSL), you are actually writing to your hard drive instead of RAM as on a standard Linux OS. You should see GB/sec speeds when writing to RAM vs MB/sec speeds to HDD/SSD. Cygwin has had the same issue, using HDD instead of RAM for /dev/shm/ and /run/shm/ too.

Why use /dev/shm for IPC

For programs very aggressively using shared memory for heavy writing operations, WSL can cause two slowdown problems:

  1. order(s) of magnitude slower /dev/shm/ operations on WSL and Cygwin since HDD is being used instead of RAM
  2. wearing of solid state drive if /dev/shm is pointed there (e.g. your C: drive)

Example WSL /dev/shm/ use

 dd if=/dev/zero of=/dev/shm/blah bs=10M count=100

You’ll see hundreds of MB/sec if using an SSD, tens of MB/sec with HDD, while you should see GB/sec if using RAM like a normal Linux machine.

df -h

Note your space used, after doing the following line you’ll see 1 GB was freed.

rm /dev/shm/blah

Leave a Comment