I asked this question almost a year ago but did not have much luck. MikTex's PDFLaTeX has been updated since, but the error is still there:

! TeX capacity exceeded, sorry [save size=50000].

Full source code at http://pastebin.com/XHazZ7Ux

Error log: http://pastebin.com/DtFcT9Cv

Same error with LuaLatex.

Hopefully this time some will be able to shed light on the limitation, why is it in place and what can be done to increase the amount of memory available to compilation.

  • 2
    Do you really think to typeset such a gigantic tree? – egreg Mar 19 '15 at 21:31
  • Yes, I really need to do that. But let me ask you, in the age of hundreds of GB of RAM is that really that audacious? (Especially when we are talking of what - 50K or 80K of RAM). – ajeh Mar 20 '15 at 12:51
  • 1
    What's exhausted is the “save size”, that is the memory used to store values when TeX enters a new group. I don't know the exact implementation of forest, but probably it uses groups for drawing the subtrees, which means that you either exhaust the save size or the “nest size” because you open too many groups. LuaTeX uses dynamic memory allocation for the main memory, but it still follows TeX's model in some parts (the save size and the nest size among them). In TeX Live the nest size is set to 500. – egreg Mar 20 '15 at 12:57
  • 2
    I tried with LuaLaTeX on a Unix system with the command line save_size=1000000 lualatex bigforest (I removed the inessential tabular and left just the code for the tree); painfully slow, at the end I got ! Dimension too large.. Lengths can't exceed 2^30sp, that is 5.75 meters. – egreg Mar 20 '15 at 13:04

If I compile on my system with

save_size=1000000 lualatex bigforest

I get no TeX capacity exceeded error, at least until the

! Dimension too large.
<recently read> \pgf@x 

l.4628 \end{forest}

error shows up. So one can certainly lift off the limitation on the save size (LuaTeX needs to allocate some special space for it, but it's extendable at run time). However the limitation that lengths mustn't exceed 230 scaled points, that is, about 5.75 meters (slightly less than 18.9 feet) can't be removed.

  • What would be the complete command line for that? – ajeh Mar 20 '15 at 13:23
  • @ajeh I really don't know the equivalent for MiKTeX. However, the size error is fatal. – egreg Mar 20 '15 at 13:25
  • MikTex uses the same commands as TexLive. I tried lualatex --shell-escape --save_size=1000000 --lualatex --bigforest chart.tex but got the same error as previously. – ajeh Mar 20 '15 at 13:33
  • 2
    @ajeh I doubt very much that egreg's copy of lualatex features a --bigforest option. egreg's file is bigforest.tex. Yours is chart.tex. So save_size=1000000 lualatex chart would be equivalent (adapted for MiKTeX). – cfr Mar 20 '15 at 17:00
  • Slap on the forehead smilie! Of course, it's a file name sans .tex extenstion. I should have figured it out. But anyhow, see my answer for the exact name of the config file below. – ajeh Mar 20 '15 at 20:25

It seems that the main culprit for the error is PGF/TikZ, which causes save stack buildup by mixing local and global assignments to \pgf@x and \pgf@y.

As these two \dimen registers are used extensively in PGF's internal computations, it makes sense that larger trees, or longer documents in general, will exhaust the save stack.

The only solution I see is that someone goes through PGF/TikZ code and fixes the usage of these registers. They have 5313 occurrences in PGF/TikZ code; 590 of them are easily recognizable as assignments as they are followed by =. :-(

EDIT: Actually, and seriously. \pgf@x and \pgf@y are only assigned globally in a couple (about 50 easily recognizable) places in the entire PGF/TikZ. If those assignments could be fixed, maybe through the introduction of \pgf@x@global and \pgf@y@global, the task would actually be manageable (disregarding third party packages and user macros here...).

  • Good to hear from you Sašo, I really appreciate you looking into this! – ajeh Jan 19 '17 at 23:02

Solved that by editing \Program Files (x86)\MiKTeX 2.9\miktex\config\texmf-defaults.ini and changing the line

save_size=1000000 ;;50000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.