The command is like this:
gs -q -dSAFER -dBATCH -dNOPAUSE -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite -sOutputFile=output.pdf 1.pdf 2.pdf ... N.pdf
Each input PDF contains many images, and most images are shared among input PDFs.
The command runs successfully. Memory usage increases incrementally, and finally reaches 3.7GB. I have tried various PDFSETTINGS: prepress / printer / ebook / screen. The max memory did not reduce.
I want to know is it possible to reduce GhostScript memory usage? Longer CPU processing time is acceptable.
$ gs -v GPL Ghostscript 9.25 (2018-09-13) Copyright (C) 2018 Artifex Software, Inc. All rights reserved.