memory

Reports how much memory is available and in use.

Category: Software Development Tools > Performance and Memory

Syntax

m = memory

Returns a struct with memory figures, in bytes.

Description

MemUsedMATLAB is the memory the session currently uses, MemAvailableAllArrays is what is available for arrays in total and MaxPossibleArrayBytes is the size of the largest single array that could still be created. All three are in bytes and change from one call to the next.

It helps to check whether a very large array is feasible before allocating it.

Output arguments

m
Struct with fields MaxPossibleArrayBytes, MemAvailableAllArrays and MemUsedMATLAB.

Example

Memory fields

m = memory;
fieldnames(m)
disp(m.MemUsedMATLAB > 0)
Output
ans = 3×1 cell

    {'MaxPossibleArrayBytes'}
    {'MemAvailableAllArrays'}
    {'MemUsedMATLAB'        }
   1

See also

whos clear inmem cputime