MATLAB memory pileup in batch printing of figures

2019-07-16 18:59发布

问题:

I am printing a large number of figures to files. After a certain number, I get an out of memory error which a lot of other people have reported as well.

This question addresses the problem, but I cannot use the solution as I am printing various kinds of graphs including surface, plot, contour, quiver and scatter.

Is there a practical solution or a feasible workaround for this memory pileup problem that would allow to run the entire image printing in an unsupervised batch?

回答1:

This seems like a memory leak. You may be able to help Matlab release the leaked memory by closing each figure after printing. Create a new figure for each thing you want to print.

% item 1
f = figure;
% plot
% print
close(f)

% item 2
f = figure;
% plot
% print
close(f)