# Compiler error “save size exceeded”

I have a problem with compiling my thesis. Due to a new plot I inserted, it lo longer compiles.

According to this guide, i increased the limits for lualatex as follows:

pool_size=5000000
main_memory=6000000
extra_mem_bot=2000000
font_mem_size=2000000
save_size=120000


And saved them:

initexmf --dump=lualatex


Nevertheless, I receive this error message:

! TeX capacity exceeded, sorry [save size=80000]. \pgfplotsarraysort@iflt ...then@b =\pgfmathresult \ifdim \pgfplotsplothandle... l.45682 \end{axis} If you really absolutely need more capacity, you can ask a wizard to enlarge me.

Here is how much of LuaTeX's memory you used: 114715 strings out of 495013 100000,36569284 words of node,token memory allocated 25514 words of node memory still in use: nodes avail lists: 1:1,2:35,4:2165,5:257,6:3245,7:522,8:5,9:1078,10:558,11:1 115594 multiletter control sequences out of 65536+200000 197 fonts using 5517751 bytes 68i,19n,144p,1144b,79999s stack positions out of 5000i,500n,10000p,200000b,80000s ! ==> Fatal error occurred, no output PDF file produced!

As I see it, my changed up the limit to 80k (was 50k) but this seems to be a hard limit.

Minimum Working example:

\documentclass[12pt, a4paper, bibliography=totoc, listof=totoc, parskip=half, numbers=noenddot]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[english, ngerman]{babel}
\usepackage{lmodern}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{tikz, tikz-3dplot, pgfplots}
\usepackage{siunitx}
\usepackage{tikz, tikz-3dplot, pgfplots}
\pgfplotsset{compat=1.9}
\usetikzlibrary{shapes, arrows, plotmarks, calc, fpu, positioning, fit, fadings, external}
\tikzset{>=latex}

\begin{document}

\begin{figure}[htb]
\centering
\input{diff_slice_KV-Referenz_131.tikz.tex}
\caption{Problematic plot}
\label{fig:iterpower_Referenz}
\end{figure}

\end{document}


The inputfile for the plot is found here: https://www.dropbox.com/s/osl8ulsukcrasip/diff_slice_KV-Referenz_131.tikz.tex

I also tried to use XeLaTex, but I got the same error as with pdflatex a long time go: "main memory size" exceeded. (That was the reason to switch to lualatex in the first place)

I know this is taxing on tex, but all the other surface plots work fine. This slice plot, which is comprised of two surface plots, apparently pushes lualatex over the edge. It was generated by matlab2tikz, therefore I assume it should be syntactically correct. (All the other surface plots are) Also, I have tested a smaller slice plot, that is slow (as always) but renders okay.

Is there any way I can render this plot with pfgplots?

The questions, that cover the same error, suggest that I cannot raise the limit over 80k, and that maybe something in the code is wrong. But I don't know how to trace down the error.

-
See also Increasing TeX's main memory. –  Martin Schröder Feb 20 '14 at 10:03
Exhausting the save size usually means that too many values are being retained; doing local and global assignments to the same variable is a frequent cause for this. –  egreg Feb 20 '14 at 10:48

The human eye cannot distinguish 46000 discrete samples in a region of about 50 cm2 on a printed page anyway. Downsample your data in MATLAB before plotting there and running matlab2tikz. If you absolutely must keep the plot of the full data set in MATLAB, produce a separate downsampled plot for use with matlab2tikz.