Clear Filters
Clear Filters

exportgraphicsunusably slow and memory overruns

28 views (last 30 days)
I'm using exportgraphics built-in on a simple figure (four subplots, each one is a scatter plot of 500 data points, nothing crazy). When I call exportgraphics(gcf,'myfile.pdf'), it goes "busy" for up to five minutes and then throws a java heap space memory error. I'm using MATLAB R2020b on an iMac running OSX 13.6. It doesn't seem to matter how minimal of a figure I try to export; it always hangs and then errors. I mean, this function should be expected to work, right? What gives?
Just to quickly follow up: if I shut everything down, restart, open a fresh instance of MATLAB and then run this MWE, then I can just barely get it to export:
theFigure = figure;
scatter(randn(500,1),randn(500,1));
tic
exportgraphics(theFigure,'/users/adam/desktop/test2.pdf');
toc
Elapsed time is 40 seconds... should be faster than that, no?
Hm... if I run the same code again immediately after that without making any other changes, then elapsed time is closer to 1 second. Still very slow, but why is the first instance 40 seconds then but the next call is only 1 second? Why is it I can't even get it to output anything at all reliably if the figure is even moderately sized? This should be a very basic function to save graphics, right?

Answers (1)

Matt J
Matt J on 8 Dec 2023

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!