I have a large project (a book) of c 450 pages in length. I am using TexShop on OSX with LaTeX to produce a PDF.

The project builds on the first pass, but on the second pass when it is filling in the contents and cross references it fails with:

(/Users/Sean/PIC/BookLibraries/LUT.X/LUT2.asm [281])
./subroutines.tex:130: TeX capacity exceeded, sorry [main memory size=5000000].
<argument> ...p_box \vbox_unpack:N \l_shipout_box 
                                                  \kern \c_zero_dim 
l.130 }
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

Here is how much of TeX's memory you used:
 102928 strings out of 479917
 2426234 string characters out of 5882726
 4999999 words of memory out of 5000000
 105338 multiletter control sequences out of 15000+600000
 755283 words of font info for 339 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 146i,20n,184p,2382b,2938s stack positions out of 5000i,500n,10000p,200000b,80000s
./subroutines.tex:130:  ==> Fatal error occurred, no output PDF file produced!

The location of failure is in a Listing but is not remotely unusual, there are many such in the book.

I have altered the .../texlive/2020/texmf.cnf by adding

main_memory = 600000 % words of inimemory available; also applies to inimf&mp
main_memory.tex = 600000
main_memory.latex = 600000
main_memory.pdflatex = 600000

but as the error still reports a main memory size of [main memory size=5000000] at failure.

Are there are other parametrs I can vary?

  • First of all you should show some code, as this might stem from a badly programmed macro that ends up in the toc and is, say, expanded too early
    – daleif
    Commented Oct 16, 2020 at 11:08
  • Thanks, I could do so, but the specific question is why the error message insists the memory size is 5000000 when I have altered the memory size in what I think are the likely sections to 6000000. There is so much code that it is difficult to think of an MWE. A link to an earlier version of the pdf generated is here: stbarnabaschapel.net/book1.pdf Commented Oct 16, 2020 at 12:40
  • This tex.stackexchange.com/questions/438902/… will helps you
    – MadyYuvi
    Commented Mar 4 at 12:11

1 Answer 1


This works in my case at least and I ave simulated the anticipated final size of the book c 900 pages by duplicating Chapters. It may be of some help if others are genuinely running out of memory.

main_memory = 12000000
extra_mem_bot = 12000000
font_mem_size = 12000000
pool_size = 12000000
buf_size = 12000000
  • 2
    For completeness, and for the answer to be a helpful reference to others, it's important to mention the following: for the changes to come into effect at all, "[we] have to redump the .fmt file after changing main_memory" (quote from textmf.cnf). This is done by running fmtutil. The syntax under OSX has changed a bit over the years; currently (OSX 10.15) you can run sudo fmtutil --sys --all in the Terminal.
    – marquinho
    Commented Jul 17, 2021 at 12:19
  • For those interested in understanding more regarding the difference between sudo fmtutil --sys --all and sudo fmtutil-sys --all for example, tug.org has a concise description of, and the differences between fmtutil, fmtutil-sys, and fmtutil-user at tug.org/texlive/doc/…. Commented Apr 13, 2023 at 3:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .