# Increasing memory

I am working on a document which produces ~4000 pages, each with at least 30 graphics per page. There is a lot of font switching and colouring different characters different colours. I am able to limit the pages outputted, which allows me to successfully compile. I'm using MikTex 64-bit but noticed the same problem when attempting through texLive.

However, when I attempt to increase the number of pages beyond a certain amount, LuaLaTex quits with:

! TeX capacity exceeded, sorry [number of strings=493869].
<argument> ...ter {\reserved@b Pianos/256px/F/Piano_482.png}
\ifeof \@inputcheck \else ...

l.33572 ...m]{{Pianos/256px/F/Piano_482.png}}F ♮3}
& \textcolor{F-Lt}{F} &  ...

47374 words of node memory still in use:
972 hlist, 276 vlist, 615 rule, 1 adjust, 7 disc, 276 local_par, 7 dir, 4 ma
th, 1376 glue, 30 kern, 388 penalty, 96 unset, 596 glyph, 16 align_record, 3318
attribute, 142 glue_spec, 1660 attribute_list, 14 temp, 1 align_stack, 4 if_st
ack, 1 pdf_dest, 3 pdf_action, 412 pdf_colorstack, 26 pdf_setmatrix, 26 pdf_sav
e, 26 pdf_restore nodes
avail lists: 1:1,2:32136,3:1080,4:450,5:513,6:468,7:9915,8:39,9:4238,10:45,1
1:507
!  ==> Fatal error occurred, no output PDF file produced!
SyncTeX written on document.synctex.gz.
Transcript written on document.log.


I can't really post an MWE because I think the glitch comes mostly from including images thousands of times. I am trying to pass the command line option into lualatex with -extra-mem-top=50000000.

I did also try editing my textmf file but it didn't seem to actually change that magic number (493869) number of strings. I am also running the 64-bit version of the binaries because I read that it could help with the memory allocation but it did not actually change anything.

• you say at the top that lualatex quits but then you say you use the pdftex command which do you want to use (this makes a big difference here as lualatex uses dynamic memory allocation and pdftex does not) – David Carlisle Nov 29 '19 at 9:42
• Indeed, I would like to know how this happens, since I am using luaLaTeX and I thought there cant happen situations like this. Mainly because of that I faved the question ... – Tomáš Kruliš Nov 29 '19 at 9:46
• then I suggest you edit the question not to mention pdftex! but you have run out of string pool not main mem so in texmf.cnf that is max_strings_ not extra_mem and possibly some of the others in teh string group % Max number of characters in all strings, including all error messages, % help texts, font names, control sequences. These values apply to TeX. pool_size = 6250000 % Minimum pool space after TeX's own strings; must be at least % 25000 less than pool_size, but doesn't need to be nearly that large. string_vacancies = 90000 % Maximum number of strings. max_strings = 500000 % min – David Carlisle Nov 29 '19 at 10:07
• I suspect from the form of your error message that you are using \graphicspath really I would not use that in your case that is multiplying your string usage by the one more than the number of items in the path list. – David Carlisle Nov 29 '19 at 10:41
• @DavidCarlisle I am sorry, I might have confused you Mr. Carlisle. I am not the original person who wrote the question, I am just very interested in knowing, what is the cause of the error posted by question author. – Tomáš Kruliš Nov 29 '19 at 10:44

LuaTeX uses dynamic memory allocation for main mem so the texmf.cnf setting you are using would have no effect even if you set if for luatex rather than pdftex.

However it does still inherit some fixed array usage from classic tex, including the number of strings.

this produces the error that you state (note it is an infinite loop so it relies on an error condition to terminate.

\documentclass{article}

\begin{document}

\loop
\iftrue
\expandafter\def\csname zzz\the\count0\endcsname{}
\repeat
\end{document}


This produces

LaTeX2e <2019-10-01> patch level 3

luaotfload | main : initialization completed in 2.242 seconds
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/10/25 v1.4k Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo)) (./cc372.aux)
! TeX capacity exceeded, sorry [number of strings=493861].


You can increase the number of strings by calling it as follows (or by editing texmf.cnf)

$max_strings=1000000 lualatex cc372 This is LuaTeX, Version 1.10.0 (TeX Live 2019) restricted system commands enabled. (./cc372.tex LaTeX2e <2019-10-01> patch level 3 luaotfload | main : initialization completed in 2.141 seconds (/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls Document Class: article 2019/10/25 v1.4k Standard LaTeX document class (/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo)) (./cc372.aux) ! TeX capacity exceeded, sorry [hash size=665536]. <recently read> \endcsname  Now you see it has not run out of strings but has overflown the hash table, which could be similarly increased. You need to iterate on your real document to increase whatever is needed. Here, if I increase the size of the hash table enough, it takes several seconds to run, but eventually runs out of strings again: $ max_strings=1000000 hash_extra=1000000 lualatex cc372
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
restricted system commands enabled.
(./cc372.tex
LaTeX2e <2019-10-01> patch level 3

luaotfload | main : initialization completed in 2.187 seconds
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/10/25 v1.4k Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo)) (./cc372.aux)
! TeX capacity exceeded, sorry [number of strings=993861].

• I'm using texWork and added what you have written as a command argument. Is that how cc372 is supposed to be used? When I run this I get This is LuaTeX, Version 1.11.2 (MiKTeX 2.9.7250 64-bit) restricted system commands enabled. ! I can't find file max_strings=1000000'. <*> max_strings=1000000  Also I just want to point out that I will actually need about 5 or more times the capacity that I have, just to compile my current draft. If I had about 20 times more, I could actually finish expanding my format how I originally have designed it. – The Real Dre Nov 29 '19 at 13:06
• cc732 is just the random filename I used in this answer (the 732rd answer I have posted since I started using cc prefix..) as I commented under the question, you are almost certainly using more string space than needed so fixing that rather than allocating an ever bigger hash table is probably best. @TheRealDre – David Carlisle Nov 29 '19 at 13:37
• @TheRealDre also if you are using windows you may not be able to set the enviornment variable on the same commandline as calling luatex (I don't know) it would be simpler to edit the texmf.cnf file also this answer was texlive, I assume miktex has the same settings but I have never used it. so you might need to check.. – David Carlisle Nov 29 '19 at 13:39
• @TheRealDre Ulrike tells me that in miktex you can set this as an option to the command so the syntax is lualatex --max-strings=.... filename to process filename.tex – David Carlisle Nov 29 '19 at 13:55
• CarIisle I am using graphics path so I can switch between colour, greyscale, and also inverted colour (black paper). It would make me have to build my source tex 4 seperate times though rather than simply change my graphics directory. This is what I get when I run when you you told me in command line (or actually passing as options in TexWorks. lualatex: warning: running with administrator privileges This is LuaTeX, Version 1.11.2 (MiKTeX 2.9.7250 64-bit) system commands enabled. ! I can't find file max_strings=1000000'. <*> max_strings=1000000  – The Real Dre Nov 30 '19 at 1:06

editing lualatex.ini to use the values David Carlisle suggested, then rebuilding formats did the trick. I'm happy.

my lualatex.ini file:

main_memory=12000000
pool_size=4250000
max_strings=8000000
hash_extra=1000000


To find the path I opened the MikTeX Console and went Settings > Directory > (then the one labelled config). Open that folder and then you go ./miktex/config/lualatex.ini` from there. Thanks!