TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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[english, ngerman]{babel}
\usepackage{tikz, tikz-3dplot, pgfplots}
\usepackage{tikz, tikz-3dplot, pgfplots}
\usetikzlibrary{shapes, arrows, plotmarks, calc, fpu, positioning, fit, fadings, external}


    \caption{Problematic plot}


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.

share|improve this question
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
up vote 1 down vote accepted

Your data set is simply too large: there's no way around it.

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.

Your example code runs fine when I reduce the number of data samples to a more manageable number (I used about 10:1 resampling to get it to compile, but you could likely go even further with no loss of quality). So there is no problem with the generated code besides the fact that it's too large.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.