The evaluation of an
Export[...] expression fails with a "Not enough memory available" error, but the value returned by
MaxMemoryUsed is well below the available memory reported by the
free -b command.
I have a simple script (not a notebook) of the following form:
$HistoryLength = 0; (* probably meaningless here *) Get["dump_of_grid.mx"]; (* loads GRID *) Export["grid.png", GRID]; (* error occurs when evaluating this expression *) Print["MaxMemoryUsed: " <> ToString[MaxMemoryUsed] <> " bytes"]; Run["free -b"];
Basically, with the
Get expression, the script loads from a
DumpSave-generated file an item called
GRID, and then it immediately attempts to export
GRID to a *.png file.
More specifically, the script outputs the following:
Rasterize::bigraster: Not enough memory available to rasterize Notebook expression. MaxMemoryUsed: 487726296 bytes total used free shared buffers cached Mem: 33710690304 18287972352 15422717952 583143424 201375744 10360836096 -/+ buffers/cache: 7725760512 25984929792 Swap: 68499271680 4590067712 63909203968
MaxMemoryUsed reports 487726296 bytes, while the external command
free -b says that there are still 15422717952 bytes free.
In light of this, why would Mathematica fail with a "Not enough memory" error?
(It could be that Mathematica first computes how much memory the rasterization will require, and fails if the resulting number is greater than the available memory; if this is what happens, then the value returned by
MaxMemoryUsed is not a fair estimate of how much memory Mathematica needs. Is there some other way to get this estimate?)