MATLAB Memory: How to Fix Memory Issues Easily

  • Context: MATLAB 
  • Thread starter Thread starter Pythagorean
  • Start date Start date
  • Tags Tags
    Issues Matlab Memory
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 3K views
Messages
4,430
Reaction score
327
I've read the (a?) MATLAB file on memory on their webiste. Basically, their advice deals with data generation, which I'm not having a problem with. I generated the data sets quite easily on my 64-bit dual core, while simultaneously posting on physicsforums and playing muds.

But once I got the graphical part, my computer kept getting swamped and memory errors kept popping up (no I'm not trying to run muds or browsers with it). Basicallly, I load and plot nine sets of data (axes) on each figure, then save it as a no compression tiff.

I do this all with the visibility off, so I'm supressing graphical output. I make sure to clear the variables before I load new ones.

I can do this once manually with no problems, but if I don't quit MATLAB and reopen it, the second manual run takes much longer and bogs my computer down (even after MATLAB has crashed and closed). I got the memory errors initially when I tried to automate the whole data set at once.
 
Physics news on Phys.org
I don't for this specific case. But I remember two common gotchyas with memory in matlab.
1) don't try to plot too many points at once. Even if it's invisible.
2) make sure you're clearing big variables if you have a loop

Also, I remember Matlab was just a memory hog anyway. I've used nothing but python for the last couple years.
 
  • Like
Likes   Reactions: Wrichik Basu