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.

>> 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)
* 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.

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
Tagged on:

Please tell us what's in your mind ...

%d bloggers like this: