# capacity problem with some packages

I 'm trying to draw the plot of f(x)=sin(1/x) with pgfplot, but I get an error message:

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

I realized that when I delete one of the packages marked with %!!! in my code, everything is all right. This is the log-file.

What is going wrong?

\documentclass[a4paper,11pt,twoside]{book}
\usepackage[a4paper,left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage[english,greek]{babel}
\usepackage[utf8]{inputenc}

\usepackage{siunitx}%!!!
\usepackage{mathtools}%!!!
\usepackage{subcaption}%!!!
\usepackage[most]{tcolorbox}%!!!
\usepackage{fancybox}%!!!
\usepackage{wasysym}%!!!

\usepackage{pgfplots}
\pgfplotsset{compat=1.16}

\usepackage{tikz}
\usetikzlibrary{shapes,snakes}%!!!
\usetikzlibrary{decorations.text}%!!!
\usetikzlibrary{calc,patterns,angles,quotes,decorations.pathreplacing}%!!!
\usetikzlibrary{spy}%!!!
\usetikzlibrary{positioning,shapes,fit,arrows}%!!!

\begin{document}

\begin{center}
\begin{tikzpicture}[>=latex]
\begin{axis}[
axis x line=center,
axis y line=center,
xlabel={$x$},
ylabel={$y$},
xlabel style={below right},
ylabel style={above left},
xmin=-1.5,
xmax=1.5,
ymin=-1.2,
ymax=1.2,
ticks=none,
height=0.3\textwidth,
width=0.6\textwidth,]
\node at (axis cs:1.4,0.8) {$C_f$} ;
\end{axis}
\end{tikzpicture}
\end{center}

\end{document}


• It is a common problem that plots with too many points (or where too many things need to be calculated) can cause TeX to run out of memory. You could switch to LuaTeX, which has dynamic memory allocation and should not run out of memory that quickly (of course memory is still limited by your hardware), you could think about externalising the picture (cf. tex.stackexchange.com/q/398753/35864, if it compiles in a smaller document at all) or just produce the graph with an external application. Of course you could also choose a smaller samples value: 5000 is a lot. – moewe Mar 14 at 11:30