ImageMagick RAM with very large images
NEXRAD preview PNGs are 12200 x 5400 pixels. This takes over 650 MB of RAM to load each frame.
Problem
Normally, you should be able to control ImageMagick use of RAM with environment variables:
MAGICK_MEMORY_LIMIT
Amount of RAM heap to useMAGICK_MAP_LIMIT
Amount of RAM to use before paging to diskMAGICK_DISK_LIMIT
A very slow last resort, before crashing.
I tried commands like
MAGICK_MAP_LIMIT=2GB MAGICK_MEMORY_LIMIT=2GB
but they still paged to disk, taking 1000x longer even with SSD and wearing out the SSD with writes.
MAGICK_DISK_LIMIT=100MB mogrify -scale 10% "*.png"
would give error message as expected.
I filed an ImageMagick bug report.
Workaround
For Linux, there is a RAM drive available at /dev/shm
or /run/shm
, which is
not available
on Windows, even with Cygwin or Windows Subsystem for Linux.
I force ImageMagick to use RAM drive, which gave me 1000x speedup by:
MAGICK_TEMPORARY_PATH=/run/shm mogrify -scale 10% "*.png"