3
$\begingroup$
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] == 0, \[Rho][0] == 
    1, \[Rho][0] \[Theta]'[0] == 10, \[Rho]'[0] == 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?

$\endgroup$
3
  • $\begingroup$ 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... $\endgroup$
    – Carl Lange
    Sep 14 at 18:12
  • 1
    $\begingroup$ (You can reproduce this without creating a file by just doing Rasterize[plot, ImageResolution -> 500]) $\endgroup$
    – Carl Lange
    Sep 14 at 18:19
  • $\begingroup$ 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) $\endgroup$
    – Carl Lange
    Sep 14 at 18:42
5
$\begingroup$

This has nothing to do with system memory. System textures have limits, both in pixel dimensions and overall video memory used. On Windows, at least, the FrontEnd's threshold is set a little lower than the actual limits of D3D. Even if they were the same though, this example still would overflow well before reaching 600ppi.

$\endgroup$
6
  • 1
    $\begingroup$ How to adjust this limits? $\endgroup$
    – yode
    Sep 14 at 18:55
  • $\begingroup$ These limits cannot be adjusted. $\endgroup$
    – ihojnicki
    Sep 14 at 18:56
  • $\begingroup$ The limit is not a fixed value? Note the question supplement. I noticed that the errors were reported at different memory usage levels $\endgroup$
    – yode
    Sep 15 at 3:59
  • $\begingroup$ I guess you could render the subparts and then splice the images together again. See community.wolfram.com/groups/-/m/t/848646 the last two paragraphs that i wrote. I see you used Grid so you would have to use show and use insets to place the plots or used GraphicsGrid perhaps. $\endgroup$
    – SHuisman
    Sep 15 at 8:53
  • 1
    $\begingroup$ @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]] $\endgroup$
    – ihojnicki
    Sep 15 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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