# lack of memory for big document

I have big document in LaTeX (approx. 1000 pages, tens used packages, math, hundreds references \bibitem + \cite, cross-references \label + \ref, indices \index, tables and TikZ figures). The document is built from hundreds LaTeX files (using standalone and \input). TikZ figures are also in separate files with \tikzexternalenable (whenever it is possible), some of them have more than 1000 rows. When compiled by PdfLaTeX the TikZ figures are not recompiled (corresponding files *.dpth, *.log, *. md5 and *.pdf are unchanged with old date).

The document reached some limit because after adding new TikZ figure the compilation PdfLaTeX finish after the 2nd run with error:

• the 1st processing by PdfLaTeX finish with "Process exited normally"

• the 2nd processing by PdfLaTeX finish with error "TeX capacity exceeded, sorry [main memory size=123000000]" – every time in some TikZ file (which is not recompiled so I do not understand why problem is inside it)

In LOG file the location of error is described as follows (e.g.):

! TeX capacity exceeded, sorry [main memory size=123000000]. ...755) (1.6,0.149253036) (1.64,0. 14630663108) (1.68,0.14334... l.1661 \end{tikzpicture}

Summary in LOG file (problem is in "words of memory" record):

Here is how much of TeX's memory you used:

• 65319 strings out of 493340
• 1540999 string characters out of 3139331
• 123000001 words of memory out of 123000000
• 60823 multiletter control sequences out of 15000+200000
• 63320 words of font info for 190 fonts, out of 3000000 for 9000
• 1166 hyphenation exceptions out of 8191
• 114i,44n,128p,25560b,8155s stack positions out of 5000i,500n,10000p,200000b,50000s
• ! ==> Fatal error occurred, no output PDF file produced!

There are no syntax errors, because when I remove SOME TikZ figure then compilation is successful (I tried it with removing various figures, not with certain one).

Can somebody help me to find way for working with such big documents ?

Environment:

• Windows 10
• TexStudio 2.12.6
• MiKTeX 2.9
• PdfLaTeX command: pdflatex -synctex=1 -interaction=nonstopmode --shell-escape --enable-write18 --extra-mem-bot=120000000 ?me

Minimal Working Example is not attached, because problem occurs only with Maximal Working Example ...

Added 23.1.2018: This question was marked as an exact duplicate of an existing question - my problem is in compilation of big document with TikZ externalization in pdflatex if all (for me) known memory settings are on maximum - not "How to expand TeX's “main memory size”?"

In my case:

• externalize: it was used = no success (and still I do not understand why PDFLaTeX processes those TikZ files with big consumption of memmory while it does not create any new PDF external file for graphics ...)
• change "extra_mem_bot": it was set to maximal (possible in my PC) value 130000000 = no success
• add "extra_mem_top": I tried it with value 10000000 = no success
• add some setting to texmf.cnf: it is in TeXLive, not in TexStudio = so no success to add "save_size" or "main_memory"
• add some setting to pdftex.ini: this workaround is so suspicious that I had not enough courage to try it (especially after warnings "DO NOT EDIT THIS FILE DIRECTLY")
• use luatex: maybe, I will try, but it is run for longer distance
• I have converted all my files from Win1250 to UTF8
• I have changed several packages (for Unicode using)
• still I am not able to compile original document (e.g. luaLaTeX stops compilation after 100 errors = which in my case are undefined references typically defined in the second/third run)
• can you try luatex instead of pdftex? (luatex uses dynamic memory allocation) That said, memory is released once each page is shipped out, so large documents are not in themselves a problem, are you sure it is not one extra complicated tikz file that is killing pdftex on its own? – David Carlisle Jan 21 '18 at 11:11
• I don't have miktex (and texlive doesn't have that commandline option) but can you increase --extra-mem-bot=120000000 further? – David Carlisle Jan 21 '18 at 11:16
• If you have a lot of tikz in figure environments that are floating for several pages then tex is having to hold them all in memory, you could consider not allowing them to float so much (or at all) and place the figures in the source closer to where they finally end, and perhaps use more \clearpage to flush some out of memory at good points. – David Carlisle Jan 21 '18 at 12:08
• extra-mem-bot can be increased (in my PC) only to 163000000 - value 164000000 (and above) produces error message "Sorry, but pdflatex did not succeed" directly after PDFLaTeX start (i.e. before first run) – Ivan Kohutek Jan 21 '18 at 12:08
• I have a lot of figure environments but I prefer \begin{figure}[H] (I know that it is against TeX ideas, but I guess I need it) - so there are not many floats: Even thought I tried \clearpage after every chapter (i.e. 13 times in the document), but with no success – Ivan Kohutek Jan 21 '18 at 12:32