exportgraphicsunusably slow and memory overruns

17 visualizzazioni (ultimi 30 giorni)
Adam Snyder
Adam Snyder il 8 Dic 2023
Risposto: Matt J il 8 Dic 2023
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?

Risposte (1)

Matt J
Matt J il 8 Dic 2023

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by