[Tex/LaTex] TeX capacity exceeded with glossary package

errorsglossaries

My document contains many thousands of glossary items. When compiling with XeLaTeX, about 1/8 of the way through the document, it reports:

! TeX capacity exceeded, sorry [main memory size=3000000].
\@glolist@ ...},{13586},{9406},{4539},{12811},{179
                                                  51},{5831},{1047},{14948},
  • The numbers you see above are ones placed in #1 of \newglossaryentry{#1}{#2}. These unique numbers are assigned to each entry for convenience.
  • I have successfully compiled short tests of the document, which only used 1% of the full content.
  • The resulting .glo file is about 1 MB in size.

Could this be the result of some error on my part or am I giving TeX too much work to do?

Update:

I have followed the instructions below (edited texmf.cnf and running
fmtutil-sys --all. This has allowed me to compile an additional portion of the book, but no matter the settings I add, I can't go beyond 5/8 of the way through.

A compile with extra_mem_top.xelatex = 30000000 and extra_mem_top.xelatex = 50000000 both result in:

TeX capacity exceeded, sorry [pool size=3186676].

Update:

I have done the following:

$ kpsewhich texmf.cnf
/usr/local/texlive/2011/texmf.cnf
$ nano /usr/local/texlive/2011/texmf.cnf

To the texmf.cnf file, following instructions at Increase TeX capacity, as non-root, I added:

main_memory = 230000000
extra_mem_top = 10000000
extra_mem_bot = 10000000
save_size = 150000
stack_size = 150000

main_memory.xelatex = 30000000
extra_mem_top.xelatex = 30000000

After this, I tried:
fmtutil-sys --all, then compiling xelatex file.tex.
fmtutil --all, then compiling xelatex file.tex.
fmtutil-sys --byfmt xelatex, then compiling with xelatex file.tex.
texhash, then compiling with xelatex file.tex.

All of these resulted in no changes in results. I still get:

TeX capacity exceeded, sorry [pool size=3186676].

Best Answer

Assuming nothing is wrong with your code, you need to increase the memory TeX is allowed. Take a look here for advice on how to do that.

What to do depends on the distribution you're using, and what OS you're on. This determines where the texmf.cnf file is, which you'll need to alter.

On TeXLive 2011, it is /usr/local/texlive/2011/texmf.cnf. Following alterations to this file, run

sudo fmtutil-sys --all

in a terminal.

Related Question