4

I am trying to compile a large file which contains a tikz picture with more data points than tex can handle.

Following the questions here and here I set to increase the capacity of tex by changing the file texmf.cnf in my path /usr/local/texlive/2012. I included the line

main_memory = 10000000

and on terminal I run

sudo fmtutil-sys --all

The problem is that this memory is not enough, and numbers bigger than that don't finish the fmtutil run properly. I get the error

 fmtutil: Error! Not all formats have been built successfully.

To give a better idea of where the problem is coming from, if I only include in the file texmf.cnf the lines

main_memory.latex = 15000000
main_memory.pdflatex = 15000000

then these are the files which are not properly built:

This is a summary of all `failed' messages:
`pdftex -ini  -jobname=latex -progname=latex -translate-file=cp227.tcx *latex.ini' failed
`pdftex -ini  -jobname=pdflatex -progname=pdflatex -translate-file=cp227.tcx *pdflatex.ini' failed

How can I increase the size of the memory beyond 10000000? Am I doing anything wrong?

(BTW, I am running texlive 2012 on a mac)

Vivi
  • 26,953
  • 31
  • 77
  • 79
  • Maybe externalizing the large TikZ drawing first might help for the rest? – percusse Jul 26 '12 at 10:29
  • Can you try issuing the command shown on the last line and report the error message? You may try increasing extra_mem_top and extra_mem_bot, which doesn't require rebuilding formats. – egreg Jul 26 '12 at 10:31
  • @percusse Not sure what you mean by that... If you are saying I should try and compile the tikz file separately, then it wouldn't help because the tikz picture is all I am trying to compile (that's all that my .tex file has). If that's not what you mean, could you explain a bit more? – Vivi Jul 26 '12 at 10:33
  • Ah OK. I thought large file and TikZ drawing are different things that need to be compiled together. – percusse Jul 26 '12 at 10:34
  • @egreg: I understand what you say about extra_mem_top and extra_mem_bot and I will try that, thanks. I am not sure what you mean by "command shown on the last line", though... – Vivi Jul 26 '12 at 10:35
  • @Vivi pdftex -ini -jobname=pdflatex -progname=pdflatex -translate-file=cp227.tcx "*pdflatex.ini" (the double quotes protect the * from shell expansion). – egreg Jul 26 '12 at 10:41
  • @egreg I had no idea that was a command... Here is the error: Ouch---my internal constants have been clobbered!---case 14 – Vivi Jul 26 '12 at 10:53
  • On my system the maximum value for main_memory is 12435455 – egreg Jul 26 '12 at 11:09
  • @egreg I ran fmtutil with extra_mem_top, extra_mem_bot and main_memory all set to 12435455 and it all went OK, cheers. That improves things, though it is still not enough for even 2/3 of my file. I guess I will have to reduce the number of data points. – Vivi Jul 26 '12 at 11:18
  • @Vivi You may try using lualatex: the result should not be very different and the program dynamically allocates memory. – egreg Jul 26 '12 at 12:04
  • 1
    @Vivi First, for extending extra_mem_top and extra_mem_bot you don't need to run fmtutil. Setting them in texmf.cnf should suffice. You can also set environment variables of the same name (might be system dependent though). Secondly, 12435455 isn't the maximum by far for those two. I use 230000000 (beware of large process memory consumption). – Stephan Lehmke Jul 26 '12 at 15:42

1 Answers1

6

I don't think that increasing main_memory is the solution: the default value is very near to the maximum (which depends also on other parameter, on my system the maximum seems to be 12435455), so you get at most a 25% increase in memory.

The parameters to play with are extra_mem_top and extra_mem_bot. The former is for "small objects", the latter for "complex" ones, such as boxes.

For example, in the main texmf.cnf we find

% ConTeXt needs lots of memory.
extra_mem_top.context = 2000000
extra_mem_bot.context = 4000000

so the first suggestion is to set, in the local texmf.cnf file located in /usr/local/texlive/2012,

% Add memory to pdflatex
extra_mem_top.pdflatex = 2000000
extra_mem_bot.pdflatex = 4000000

Setting these values doesn't require to rebuild the formats, as is the case for main_memory.

An alternative is to use lualatex, which allocates memory in dynamic fashion. The result shouldn't be very different to what's obtained with pdflatex (some small changes are possible, because LuaTeX uses slightly different hyphenation algorithms, for instance).

egreg
  • 1,121,712
  • 1
    the extra memory didn't seem to help much (but then again, I could have kept trying higher numbers). The luatex option, though, worked. I never really understood what luatex was or what it did, and I didn't know how to use it. It compiled the document using all data points without problem! I truly appreciate your help :) – Vivi Jul 26 '12 at 17:38
  • If you want to increase memory as a non-root user, you can follow the instructions here: https://tex.stackexchange.com/questions/27529/increase-tex-capacity-as-non-root/27586#27586 . However, the effect is indeed limited. – fry Jun 01 '22 at 09:28
  • Is there a way to increase the memory by XeLaTeX to the biggest? – Y. zeng Sep 26 '23 at 04:33
  • @Y.zeng Did you try replacing pdflatex with xelatex? – egreg Sep 26 '23 at 08:39
  • Yes. May you tell me how to see the maximum of main_memory, extra_mem_top.pdflatex and extra_mem_bot.pdflatex? – Y. zeng Sep 27 '23 at 03:26