MATLAB: High memory usage with empty workspace

memory workspace

I am having issues with Matlab 2016b using a lot of memory even with an empty workspace as seen below.
>> memory
Maximum possible array: 13580 MB (1.424e+10 bytes) *
Memory available for all arrays: 13580 MB (1.424e+10 bytes) *
Memory used by MATLAB: 22663 MB (2.376e+10 bytes)
Physical Memory (RAM): 32768 MB (3.436e+10 bytes)
* Limited by System Memory (physical + swap file) available.
I was wondering if I can free this or prevent this from happening.

Best Answer

  • We cannot guess, which variables are still occupying the memory. Either there are some large persistent or global variables, or you call a Mex-function, which leaks memory by a forgotton free. Mex functions can reserve memory also by mexMakeMemoryPersistent or by allocating the memory statically. There are more possible reasons, but bold guessing is not efficient. Please start an observation when Matlab starts, then runs parts of your codes and check the memory consumption.