# Running out of memory when exporting at high ImageResolution

plot = Grid[
Partition[
Table[Plot[{Sin[x], Sin[2 x], Sin[3 x]}, {x, 0, 2 Pi},
PlotLegends -> "Expressions"], {k, 0, 6, 0.1}], 8],
Frame -> All];
MaxMemoryUsed[Export["p.jpg", plot, ImageResolution -> 480]]/1024/1024.


430.894

I can export it with a 480ppi resolution normally, and the MMA just costs 430M memory as the output. My computer has 32G RAM, but when I change the ImageResolution into 500 I will get a error about out of memory for Rasterize. Why? It's unreasonable. I want to export this image with 600 or 700 ppi.

If the explain of @ihojnicki is reasonable, then we will think the FrontEnd have a fixed-maximun memory to use. But let us change the plot to export:

 Clear["*"]
F[x_, k_] := -400/x^k;

equ[k_] := {\[Rho]''[t] - \[Theta]'[t]^2*\[Rho][t] ==
F[\[Rho][t], k], \[Theta]''[t]*\[Rho][t] +
2*\[Theta]'[t]*\[Rho]'[t] == 0, \[Theta] == 0, \[Rho] ==
1, \[Rho] \[Theta]' == 10, \[Rho]' == 10};

sol[k_] := NDSolve[equ[k], {\[Theta], \[Rho]}, {t, 0, 10}];

plot = Grid[
Partition[
Table[ParametricPlot[
Evaluate[{\[Rho][t]*Cos[\[Theta][t]], \[Rho][t]*
Sin[\[Theta][t]]} /. First[sol[k]]], {t, 0, 10},
PlotRange -> All, PlotTheme -> "Scientific",
PlotLabel -> "label \[Alpha]=" <> ToString[k],
FrameLabel -> {"x", "y"}], {k, -3.6, 2.7, 0.1}], 8],
Frame -> All];

MaxMemoryUsed[Export["p.jpg", plot, ImageResolution -> 650]]/
1024/1024.


1104.06

Note I can use nearly 1G memory now. But when I change the 650ppi into 700ppi I will get a same error about out of memory. Isn't the limit fixed?

• I also get this issue with that code snippet (changing ImageResolution to 500) on my machine, which has 96 gigabytes of RAM. I wonder if it is something other than a memory issue... Sep 14 at 18:12
• (You can reproduce this without creating a file by just doing Rasterize[plot, ImageResolution -> 500]) Sep 14 at 18:19
• Interesting: Export["p.png", Show@plot, ImageResolution -> 500] works just fine, even though it complains that Grid is not a type of Graphics. I wonder if there's some sort of check against the Head of the expression to be rasterized. (Though it does again begin to fail at ImageResolution -> 680) Sep 14 at 18:42

• @yode, perhaps this code chunk would better explain the particular limit you are running into. CanFitToday[content_, ppi_] := Module[{result = Quiet@Rasterize[content, ImageResolution -> 72]}, If[FailureQ[result], False, Max[ImageDimensions[result]] * ppi / 72 <= 15000]]` Sep 15 at 13:00