- Avoid plots with illegibly large amounts of data. The million-line plots and the box plots with millions of outliers are consuming large amounts of memory. For plots like those, MATLAB is probably creating millions of objects in a complex hierarchy, which decreases performance and uses lots of memory.
- Clear the plots that you are finished with in order to free memory along the way.
- If you encounter memory-related issues even after removing the memory-hog plots as suggested above, it may be helpful separate the simulation and plotting into distinct steps, shutting MATLAB down in between.
Matlab R2020b on Linux Lite CPU spiking.
2 views (last 30 days)
Show older comments
I've seen the same issue for other versions of Matlab and tried all of those fixes but nothing has worked.
Often when just plotting a figure the CPU spikes and Matlab freezes.
Any suggestions?
0 Comments
Answers (1)
Rishav
on 7 Jun 2024
Hi Naoise,
It is possible that the sheer volume of data being plotted is the root cause of the memory overflowing and CPU spikes. Please try the workarounds stated below:
The best way to do this is to start MATLAB from the command line, run your simulation, save its results, and exit. Then, for each plot, start MATLAB, load the results, create the plot, save, and exit. The link below explains how to start MATLAB from the command line:
You can use the '-r' option to execute MATLAB code. For example, you start MATLAB from the command line like so:
cd "C:\Program Files\MATLAB\R2020b\bin"
matlab -nodesktop -nodisplay -r "mySimulationScript; save('my_simulation_data.mat'); exit"
Please see the following documentation in order to address memory issues in MATLAB:
0 Comments
See Also
Categories
Find more on Measurements and Feature Extraction in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!