Matlab suddenly has issues with plot manipulation (like rotation) as well as adding paths

Up until ten days or so, my Matlab 2021a was working fine. I am regularly plotting some FEM meshes in 3d, and I know I was able to (up until a week or two) normally manipulate figures, i.e. to rotate/zoom/move etc. As I save a lot of those, I noticed that even figures up to 1GB in size would be doable, in a sense that they might be a bit slow/clunky but fast enough to see a mesh from all sides in a reasonable amount of time.
Now, opening a 5-30 MB figures completely breaks everything. Matlab becomes unusually slow, e.g. rotation is extremely slow and once I click anywhere inside the plot it takes 10-20 seconds to get any kind of response from the figure, let alone the rotation you wanted to make with your pointer. At that time everything within Matlab freezes up completely. I'm essentially opening the same figures on which I've worked on a week or two ago, and a figure of this size (the exact same one) was not exhibiting any slow behaviour then. This of course also happens with figures my code outputs.
Moreover, I have a script which is essentially 30-40 calls of the "addpath Some_Path". Up until now, it was executed in a negligible amount of time, whereas now it takes 4-5 seconds for the same calls. I know these issues seem unrelated at first, however I just wanted to to point out they appeared at the same time.
I'm running MATLAB on Windows 10 (now 11 after updating it today) , I have 16 GB of RAM and a i7-1185G7 processor. I want to emphasize again, that this is a sudden change, and I have not modified anything regarding Matlab or Windows at the time when these issues began to appear. I have very little software installed on this system and the laptop itself is almost new, so I'm certain that nothing else is "taking RAM away" from Matlab. I noticed that right at the startup, Task Manager shows Matlab occupying almost 2GB RAM, which seems a bit excessive. (I haven't modified/created any startup scripts)
What I've tried so far:
  • Reistalling MATLAB
  • Updating to 2021b (from 2021a)
  • Updating Windows as well as switching to Windows 11 as of today
  • Checking Java heap memory (default value, 1152MB)
None of these have helped so far.

8 Comments

"Moreover, I have a script which is essentially 30-40 calls of the "addpath Some_Path"."
Using the MATLAB search path to access data files is not recommended, not required, and generally inefficient.
"I know these issues seem unrelated at first, however I just wanted to to point out they appeared at the same time."
A hunch based on many threads on this forum: your search path includes either cloud/server locations or folders with large numbers of files in them, which are slowing down MATLAB... because of bad code design which manipulates the search path to access data files (and so forces MATLAB to continuously scan the added folders).
Solution: better code design using absolute/relative filenames to access data files.
I'm sorry, let me make sure I didn't misunderstand. The locations are all local, nothing is on a server/cloud. I keep my code in different subfolders and I use addpath to make all of the code usable. The only things inside the subfolders are .m scripts.
@DBoss: even local folders can slow down MATLAB, if the number of files is large:
How many MATLAB files do you have?
How many data files do you have?
Are they kept strictly in separate folders?
Do you have any cloud services on your computer or any that you directly access: OneDrive, etc. ?
"The only things inside the subfolders are .m scripts."
You write scripts for code of that complexity?
@Stephen there are 378 files, separated into 41 folders and subfolders all together. The total size is around 1 megabyte. This really doesn't seem like all that much honestly. All of the files are .m MATLAB files, as I do not currently take any data as input. The thing is, this amount of the files has not suddenly changed significantly, whereas MATLAB's behaviour did.
@DBoss: okay, then we move onto the next tact: what changed 10 days ago?:
  • changes to your MATLAB code
  • app updates
  • OS changes
  • network changes
  • ... ?
You wrote that "I have not modified anything regarding Matlab or Windows at the time when these issues began to appear", but unfortunately changes are sometimes automatic or seem unrelated (e.g. new serives by the OS, etc.)
Do you have backups/code versioning? Can you do a diff between the code before and after?
@Stephen That is really something that I'm confused about as well. I know Windows has been asking me to update for a few weeks (even from before the issues began), and I am certain did not do it up until now, and I always disable automatic updates and do it manually. The fact that a clean reinstall of Matlab, and with a different version, did not help at all points me towards a problem outside of Matlab, but I'm really unsure what it could be. I do have backups of the code, but even without me running any of my code, these problems persist. If I just start Matlab up, and do nothing but open a 30 megabyte figure it starts being extremely slow. (I try out simple commands like addition/multiplication until I know Matlab is working normally, just to make sure that any potential initialization is done with).
I only have an integrated GPU, and it doesn't seem like there are issues with it. Another thing I noticed, is that for the people around me, on startup of Matlab, the task manager reserves 700-900MB of RAM, whereas for me a fresh startup of Matlab will appear with nearly 2GB of RAM. I know this is just reserved, not neccessarily used memory, but perhaps it is indicative of some other potential issue.
" but even without me running any of my code, these problems persist"
Ah, that is interesting.
"...for the people around me, on startup of Matlab, the task manager reserves 700-900MB of RAM, whereas for me a fresh startup of Matlab will appear with nearly 2GB of RAM"
Do you have a STARTUP file or MATLABRC file or anything else that runs when MATLAB starts?
Contact TMW technical support, they can probably help with this kind of issue easier than the volunteers here:
I have not in any way modified any of those.
I'll contact the support then as well, thanks a lot for your time!

Sign in to comment.

 Accepted Answer

So it appears I manged to resolve the issue, though I did not yet get a response from the support.
If you have this issue, or potentially other (slow) plotting issues, check Resolving Low-Level Graphics Issues. Short version here:
Check the status of your renderer with info = rendererinfo(gca). For me, it was set to OpenGL software, and changing it to hardware using the command opengl('save','hardware') resolved the issue. Note that you have to restart Matlab for this command to take effect.
The issue was also resolved when using opengl('save','hardwarebasic').

1 Comment

I had about the same issue and setting from 'hardware' to 'software' did the trick.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2021b

Tags

Asked:

on 21 Mar 2022

Commented:

on 30 Oct 2025

Community Treasure Hunt

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

Start Hunting!