r/linux4noobs • u/DrJohnEZoidberg • 1h ago
shells and scripting Ghostscript ram usage ballooning
I've been messing around with so pdfs and had found a program that would convert them into signatures for bookbinding, but now when I open the pdfs that have been converted gs.bin balloons in ram usage to 6 or 8gb and make my computer effectively crash, everything will freeze or just slow way down for a few minutes.
Is there a way to control the ram usage?
I'm on opensuse
1
Upvotes
View all comments
1
u/scraping_solutions 1h ago
gs.bin is Ghostscript itself, so first check which program is starting it, for example with pstree -p or ps -ef | grep gs.bin, since many viewers and thumbnailers only hand a file to Ghostscript when they can't render it themselves. Imposition tools sometimes place every page as a full copy of the original or turn pages into large images, so the output can be much heavier to render than the source even if it looks the same. Compare the file sizes, and pdfimages -list on the converted file will show if the pages became huge images.
To stop it from freezing the whole system you can cap the memory of whatever you launch with systemd-run --user --scope -p MemoryMax=2G followed by the command. Then that process gets killed when it hits the limit instead of pushing everything into swap. If you ever run gs directly, -dMaxBitmap and -dBufferSpace control how much it keeps in memory, and lower values make it render pages in bands.