Below is an attempt at cleaning some memory from Matlab, it seems that "clear all" is giving me less memory.
I am using a custom GUI using the the old figure, not the uifigure, not sure if this would help. Also using some .NET structures, but I am careful about clearing these in my code, and most of those structures are small.
I suspect that some java variables are not being cleaned, most likely when Images are being relpaced on an images axis as this is the biggest memory use.
32GB of memory is a lot to use without any variables in the work space!
Is there a way to clear free RAM without restarting Matlab? Ideally I would like to be able to run a clean up without having to close my GUI or clear my workspace.
>> memory
Maximum possible array: 16540 MB (1.734e+10 bytes) *
Memory available for all arrays: 16540 MB (1.734e+10 bytes) *
Memory used by MATLAB: 33625 MB (3.526e+10 bytes)
Physical Memory (RAM): 32684 MB (3.427e+10 bytes)
* Limited by System Memory (physical + swap file) available.
>> clear all
>> memory
Maximum possible array: 11476 MB (1.203e+10 bytes) *
Memory available for all arrays: 11476 MB (1.203e+10 bytes) *
Memory used by MATLAB: 32313 MB (3.388e+10 bytes)
Physical Memory (RAM): 32684 MB (3.427e+10 bytes)
* Limited by System Memory (physical + swap file) available.
>> clearvars -global
>> memory
Maximum possible array: 10238 MB (1.074e+10 bytes) *
Memory available for all arrays: 10238 MB (1.074e+10 bytes) *
Memory used by MATLAB: 32313 MB (3.388e+10 bytes)
Physical Memory (RAM): 32684 MB (3.427e+10 bytes)
* Limited by System Memory (physical + swap file) available.
>>