[Tex/LaTex] Increasing TeX’s main memory

memorypdftexpgfplotstikz-pgf

I have a plot with a lot of measurement datapoints. I exported this plot from Matlab2tikz.

When I tried to compile, it said that the memory was exceeded. I found this question and it tells me that I can export different tikzpictures to different files. Unfortunately, this didn't help me since I have only 1 tikzpicture causing the problem.

So I actually tried to increase the memory of TeX. I went to /usr/share/texlive/texmf/web2c then in texmf.cnf I changed main_memory = 3000000 to main_memory = 5000000. Then I ran texhash and tried to compile my TeX file again.

My problem is that after I increased the memory limit I got again the same error: ! TeX capacity exceeded, sorry [main memory size=3000000]. However I just changed it to 5000000. I presume that I did something wrong when increasing the memory limit. Did I?

-Edit-

Eventually I just used lualatex. This was due to the fact that I think there is something wrong with my texlive install: it is installed twice on my system for some reason. I think, however, that Heiko Oberdiek's answer is correct and hence marked it as the correct answer.

Best Answer

From texmf.cnf:

% Memory. Must be less than 8,000,000 total.
%
% main_memory is relevant only to initex, extra_mem_* only to non-ini.
% Thus, have to redump the .fmt file after changing main_memory; to add
% to existing fmt files, increase extra_mem_*.  (To get an idea of how
% much, try \tracingstats=2 in your TeX source file;
% web2c/tests/memtest.tex might also be interesting.)

Thus you have to regenerate the format files (fmtutil) to see an effect of changing main_memory.

Related Question