Clear Filters
Clear Filters

Matlab R2020b on Linux Lite CPU spiking.

1 view (last 30 days)
Naoise Holmes
Naoise Holmes on 26 Feb 2021
Answered: Rishav on 7 Jun 2024
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?

Answers (1)

Rishav
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:
  1. 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.
  2. Clear the plots that you are finished with in order to free memory along the way.
  3. 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.
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:

Categories

Find more on Startup and Shutdown 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!