2

I have faced an error when running file .tex using MiKTeX.

TeX capacity exceeded, sorry [main memory size=3000000]

I already tried to use many solutions including the following: How to expand TeX's "main memory size"? (pgfplots memory overload)

As said in the link, I tried to solve by using

\usepgfplotslibrary{external}
\usepgfplotslibrary[external]
\tikzexternalize

and -shell-escape

However, it did not work in my case.

This is my code for plotting:

\begin{figure}[!ht]
\centering

\input{figs/aa/aa.tex}
\caption{aa}
\label{fig:aa}
\end{figure}

aa.tex is the file that I exported from MATLAB using Matlab2tikz.

In my latex file, I also plot figures from another Matlab2tikz files. But only have error with aa.tex file. So I thought file its size is too large.

This is the file: https://drive.google.com/open?id=0Bx6bUTVOinyybXNhWjBteVNzYmc

Can anybody help?

Thank you so much !

  • Welcome to TeX.SX! Please provide a MWE, so that we can see your errors. – TeXnician Mar 25 '17 at 10:50
  • 1
    Expanding main memory size will probably not help as this message is usually related to an error in your code. The more memory you provide, the more TeX will use, and will exceed it a few fractions of a second later. As TeXnician wrote, please provide your code, removing before as much irrelevant code as you can. – gernot Mar 25 '17 at 11:40
  • The only time something like that happened to me (not using Tikz), it was a relatively simple file. But I had written an infinite loop, in which one macro called another, which then called the fisrt... etc. So, as the other noted, provide some code. –  Mar 25 '17 at 13:01
  • If your aa.tex file is too big to show, then it is bigger than I want to look at. My suggestion is to throw out large sections of code and see if the problem persists. When you have narrowed it down to MWE size, try again. – John Kormylo Mar 25 '17 at 14:11
  • 4
    Try lualatex as compiler, there are no memory limits – sistlind Mar 25 '17 at 14:25
  • 4
    Your aa.tex file has over 10,000 points defined! This is the culprit. Suggest you plot it with less points you do not need such a resolution. – yannisl Mar 25 '17 at 15:38
  • 2
    Thank for all comments. Maybe the best way I can do now is to reduce the size. – Hiep Xuan Dinh Mar 25 '17 at 16:02
  • As a first approach, you can use the every nth point={} key to reduce the amount of data that is actually plotted. Decimation may however not always be applicable. Recently, another user had the same issue. Here was strategy in my thesis to solve such problems https://tex.stackexchange.com/a/536662/141947 – BambOo Apr 12 '20 at 20:38

1 Answers1

3

I had the same problem. As @YiannisLazarides pointed out, the huge amount of data is the source of the problem. I used notepad++ to reduce the amount of data. Using notepad++ it is possible to remove odd lines as pointed out in this answer. I repeat this process until the amount of data is reduced to some point that Tex can handle.

SMA.D
  • 219