Can I make GhostScript use more than 2 GB of RAM?


David Feldman

I'm running the 64bit version of GhostScript (9.50) under Windows 7 on a 64bit processor with 16gb RAM.

GhostScript returns a random error message (it will tell me there is a type error in the array command) when I try to allocate too many arrays with a total of more than 2 GB RAM.

Just to be clear, I'm watching the memory usage grow in Windows Task Monitor, not in GhostScript

I wonder why this is happening.

More importantly, I would like to know if this behavior can be overridden.

EDIT: This code produces an error -

/TL 25000 def 
/TL- TL 1 sub def 
/G TL array def
0 1 TL- { dup == flush G exch TL array put }for

The error looks like this: this is the last part of the message I get

5335 
5336 
5337 
5338 
5339 
5340 
5341 
5342 
5343 
5344 
5345 
Unrecoverable error: typecheck in array 
Operand stack: --nostringval-- --- 
Begin offending input --- 
/TL 25000 def /TL- TL 1 sub def /G TL array def 0 1 TL- { dup == flush G exch TL array put }for --- End offending input --- file offset = 0 gsapi_run_string_continue returns -20
Kens

The amount of RAM is almost certainly not the limiting factor, but it would help if you posted the actual error message. It might be "random" to you, but to someone programming in PostScript, it makes sense.

You most likely exceeded some other internal limit, such as operand stack size, but without seeing a PostScript program or error message, I can only say more. I can say that (64bit) Ghostscript will happily handle over 2GB of RAM, I ran a file last week where Ghostscript was using 8.1GB.

Note that PostScript itself is basically a 32-bit language. While Ghostscript extends many of the architectural limits documented in the PostScript Language Reference Manual (e.g., 64K elements in arrays and strings) beyond the 32-bit limit, it is largely unspecified.

As for whether you can change the behavior, it all depends on the problem, and I can't tell anything from here.

edit

Here's a screenshot of Ghostscript finishing running the test file, and the Task Manager display showing how much memory the process is using. The vmstatus I ran from the PostScript environment didn't show up afterwards. This indicates that Ghostscript thinks 10,010,729,850 bytes are in use (up to 10,012,037,312). My calculator says 9,562.8MB of memory is 10,027,322,572.4 bytes, which is a good match.

To answer the point in the comments, this is (as you probably know) on a 64-bit Windows 10 install with a lot of memory.

The difference is almost certainly an issue that has been fixed since the release of 9.52. The 9.52 64-bit binary does exit with a VMerror after (for me) 5360 iterations. Obviously it's uncommon to try to use a lot of PostScript memory (as opposed to canvas memory), not only because many PostScript interpreters simply don't allow it, so don't do much.

If you want to look at the commits and try to figure out what caused the change, you can find the Ghostscript Git repository here . You just have to go back to March of this year and it should be at 9.52 any time before March 19th.

Is there any reason other than simple curiosity to try to use up memory loads in PostScript?

enter image description here

Related