Take the 2-minute tour ×

With a very large document, after about 30 minutes of compiling with context, I get this error:

! TeX capacity exceeded, sorry [node memory size=100987760].

I added a line to texmf.cnf which says node_memory_size=1000000000, which should increase the memory size by 10 times, then ran sudo fmtutil-sys --all, but the error still appears.

  • What value do I need to change to get this document to compile?
share|improve this question
This is LuaTeX specific and doesn't have an entry in texmf.cnf, I believe. –  egreg Apr 1 '12 at 12:53
Can you close (or open) some of your other programs and run the compilation again, and see whether the second time the compilation also stops at node memory size=100987760? That should tell us whether egreg's hypothesis that it's a RAM problem is correct. If the stopping point remains 100987760, it's a TeX problem after all. [Disclaimer: I have zero experience with and zero knowledge of TeX memory problems.] –  Esteis Apr 1 '12 at 21:35
@Esteis: the number will either be the same, or a little over 2.25x that number. See my answer below for why. –  Taco Hoekwater Apr 3 '12 at 9:39

2 Answers 2

up vote 7 down vote accepted

The node memory in luatex is automatically reallocated when needed, so you have run out of memory or (more likely) run against the limit of the amount memory the operating system is willing to give to a single process.

Typically, this means a macro programming error, not a fault of luatex itself. If you run the input file with \tracingall added, you will probably see (a lot of) recurring output indicating a bad recursion somewhere. No way to tell for sure without your input, but that diagnosis is a pretty safe bet.

So why the low limit? The number you see is not in bytes but in memory words, which are typically 8 bytes. The reallocation happens using realloc(), which means that both the new and the old value are active at the same time. What you see is the old number, so the new number will be nearly 2Gb ((1+1.25) * 8 * 100987760). Add in the rest of the luatex memory in use, and with only 2GB of real memory you should no longer be surprised of the fatal error.

share|improve this answer

From the LuaTeX manual, p. 187

The single internal memory heap that traditional TeX used for tokens and nodes is split into two separate arrays. Each of these will grow dynamically when needed.

The texmf.cnf settings related to main memory are no longer used (these are: main_memory, mem_bot, extra_mem_top and extra_mem_bot). ‘Out of main memory' errors can still occur, but the limiting factor is now the amount of RAM in your system, not a predefined limit.

share|improve this answer
Does that mean I am running out of memory when running the script? I have 2 GB of RAM and 8 GB for swap. Isn't that about 100 times larger than 100987760 bytes which is appearing in the error? –  Village Apr 1 '12 at 13:09
@Village It's not the only array that's allocated and other memory can be allocated by LuaTeX, the operating system and other open programs. –  egreg Apr 1 '12 at 13:13

Your Answer


