An useful command in Matlab (Windows) is “memory”, basically, it gives you some idea of how much memory is available and how much has been used by Matlab.
1 2 3 4 5 |
>> memory Maximum possible array: 3743 MB (3.924e+09 bytes) * Memory available for all arrays: 3743 MB (3.924e+09 bytes) * Memory used by MATLAB: 1072 MB (1.124e+09 bytes) Physical Memory (RAM): 3958 MB (4.150e+09 bytes) |
1 |
* Limited by System Memory (physical + swap file) available. |
However, this command is only available in Windows platform. To find out how much free memory is available in Linux, you would need to run a system call. Here is the code that I used for this purpose.
1 2 3 4 5 6 7 8 9 10 11 |
function [mem, unit] =get_free_mem() %Usage: [mem, unit] =get_free_mem() [~,out]=system('vmstat -s -S M | grep "free memory"'); mem=sscanf(out,'%f free memory'); unit = 'MB' ; end |
Hope you find it helpful.
How to Find Out Available Memory for Matlab In Linux
thanks!