# Forest causing PdfLatex to run out of memory

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.

-
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
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
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.

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
@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

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

save_size=1000000 ;;50000

-