# TeX capacity exceeded after MikTeX update

After having updated my MikTeX distribution my document does not compile anymore (Error "TeX capacity exceeded, sorry [main memory size=3000000]"). The problem seems to be with the pgfplots package. I could reduce the problem to the following MWE (to be compiled with xelatex).

In the last plot LaTeX assumes a "Runaway definition". In the MWE I just repeated the same plot couple of times; in my real document (which loads a lot of packages and contains some text) it is sufficient to place 6 plots in a figure to get the error.

Could somebody reproduce the error?

\documentclass{scrreprt}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}

\begin{document}

\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}
\input{Test-Plots.tex}

\end{document}


with Test-Plots.tex being

\begin{figure}[htb]%
% This file was created by matlab2tikz.
%
\begin{tikzpicture}

\begin{axis}[%
width=0.808\linewidth,
height=0.637\linewidth,
at={(0\linewidth,0\linewidth)},
scale only axis,
xmin=0,
xmax=70,
xlabel style={font=\color{white!15!black}},
xlabel={x},
ymin=-5,
ymax=15,
ylabel style={font=\color{white!15!black}},
ylabel={y},
axis background/.style={fill=white},
axis x line*=bottom,
axis y line*=left,
compat=1.16,
ylabel shift={-6pt}, xlabel shift={-3pt}, tick label style={font=\tiny}, xlabel style={font=\small}, ylabel style={font=\small}
]
\addplot [color=black, line width=1.0pt, mark size=0.5pt, mark=*, mark options={solid, fill=black, black}, forget plot]
table[row sep=crcr]{%
2   0\\ 3   0\\ 4   0\\ 5   0\\ 6   0\\ 7   0\\ 8   0\\ 9   0\\ 10  0\\
11  0\\ 12  0\\ 13  0\\ 14  0\\ 15  0\\ 16  0\\ 17  0\\ 18  0\\ 19  0\\ 20  0\\
21  0\\ 22  0\\ 23  0\\ 24  0\\ 25  0\\ 26  0\\ 27  0\\ 28  0\\ 29  0\\ 30  0\\
31  0\\ 32  0\\ 33  0\\ 34  0\\ 35  0\\ 36  0\\ 37  0\\ 38  0\\ 39  0\\ 40  0\\
41  0\\ 42  0\\ 43  0\\ 44  0\\ 45  0\\ 46  0\\ 47  0\\ 48  0\\ 49  0\\ 50  0\\
51  0\\ 52  0\\ 53  0\\ 54  0\\ 55  0\\ 56  0\\ 57  0\\ 58  0\\ 59  0\\ 60  0\\
61  0\\ 62  0\\ 63  0\\ 64  0\\ 65  0\\ 66  0\\ 67  0\\ 68  0\\ 69  0\\ 70  0\\
};
\addplot [color=blue, line width=1.0pt, mark size=0.5pt, mark=*, mark options={solid, fill=black, black}, forget plot]
table[row sep=crcr]{%
2   10\\ 3  10\\ 4  10\\ 5  10\\ 6  10\\ 7  10\\ 8  10\\ 9  10\\ 10 10\\
11  10\\ 12 10\\ 13 10\\ 14 10\\ 15 10\\ 16 10\\ 17 10\\ 18 10\\ 19 10\\ 20 10\\
21  10\\ 22 10\\ 23 10\\ 24 10\\ 25 10\\ 26 10\\ 27 10\\ 28 10\\ 29 10\\ 30 10\\
31  10\\ 32 10\\ 33 10\\ 34 10\\ 35 10\\ 36 10\\ 37 10\\ 38 10\\ 39 10\\ 40 10\\
41  10\\ 42 10\\ 43 10\\ 44 10\\ 45 10\\ 46 10\\ 47 10\\ 48 10\\ 49 10\\ 50 10\\
51  10\\ 52 10\\ 53 10\\ 54 10\\ 55 10\\ 56 10\\ 57 10\\ 58 10\\ 59 10\\ 60 10\\
61  10\\ 62 10\\ 63 10\\ 64 10\\ 65 10\\ 66 10\\ 67 10\\ 68 10\\ 69 10\\ 70 10\\
};
\end{axis}
\end{tikzpicture}%
\caption[Test]{Test}%
\end{figure}

• I am wondering if your problem is related to this question. Both appear to happen after an update of pgfplots. I do not think that the accepted answer there is of any help here, though. However, apparently a bug report has been filed, perhaps it is worthwhile checking the status. – user121799 Jun 26 '18 at 23:34
• The problem seems to be somewhere else. I just tried it with an older pgfplots version - the problem is still there. Is is a xelatex issue? If I see it correctly the binaries have been updated too... – Mik Jun 27 '18 at 10:29
• Although I didn't get a final solution for the MWE here, my original document compiles after increasing the memory size as suggested by Ulrike here. – Mik Jul 2 '18 at 14:20
• I doubt that PGFPlots is the problem here, especially if you didn't had the problem before updating MiKTeX. It is more likely that one of your other packages uses much more memory after updating and thus there isn't enough left for the plots (from PGFPlots). To circumvent this problem in a large document I highly recommend using the tikz-external library. This in addition also saves a lot of compilation time, especially when the plots contain a lot of data points. Please also have a look at tex.stackexchange.com/a/341662/95441, if you decide to use the external library. – Stefan Pinnow Aug 1 '18 at 15:41