Main Content

memory

Memory information

Description

memory displays information in the Command Window about the amount of memory on your computer and the amount of memory being used by MATLAB®. You can use memory to inspect the memory details when MATLAB runs out of memory or when you notice performance regression due to high memory usage.

example

[userview,systemview] = memory returns user-focused information about memory in userview and system-focused information about memory in systemview.

example

Examples

collapse all

Retrieve information about your computer memory and display the information in the Command Window.

memory
Maximum possible array:            40212 MB (4.22e+10 bytes) *
Memory available for all arrays:   40212 MB (4.22e+10 bytes) *
Memory used by MATLAB:              4109 MB (4.31e+09 bytes)
Physical Memory (RAM):             49150 MB (5.15e+10 bytes)

*  Limited by System Memory (physical + swap file) available.

Return the user-focused memory information in a structure user. Use the structure to display the amount of memory reserved for the MATLAB process.

user = memory;
disp(user.MemUsedMATLAB)
   4.3120e+09

Return both the user-focused and system-focused memory information.

[user,sys] = memory
user = struct with fields:
    MaxPossibleArrayBytes: 4.2152e+10
    MemAvailableAllArrays: 4.2152e+10
            MemUsedMATLAB: 4.3125e+09

sys = struct with fields:
    VirtualAddressSpace: [1×1 struct]
           SystemMemory: [1×1 struct]
         PhysicalMemory: [1×1 struct]

Access the Available field of the PhysicalMemory structure to display the amount of available physical memory on the computer.

disp(sys.PhysicalMemory.Available)
   3.3494e+10

Output Arguments

collapse all

User-focused memory information, returned as a structure. userview has three fields:

Field NameField Value
MaxPossibleArrayBytes

Size of the largest contiguous free memory block, which is an upper bound on the size of the largest array MATLAB can create at this time.

This field's value is the smaller of these two values:

  • The largest contiguous memory block found in the MATLAB virtual address space

  • The total available system memory

To see how many array elements this number represents, divide by the number of bytes in the array class. For example, for a double array, divide by 8. The actual number of elements MATLAB can create is always smaller than this number.

MemAvailableAllArrays

Total memory available to hold data. The amount of memory available is guaranteed to be at least as large as this value.

This field's value is the smaller of these two values:

  • The total available MATLAB virtual address space

  • The total available system memory

MemUsedMATLAB

Total system memory reserved for the MATLAB process.

System-focused memory information, returned as a structure. systemview has three fields:

Field NameField Value
VirtualAddressSpace

Scalar structure with the fields Available and Total.

  • The value of the Available field is the amount of available virtual memory for the MATLAB process.

  • The value of the Total field is the amount of total virtual memory for the MATLAB process.

SystemMemory

Scalar structure with the field Available. The value of the Available field is the amount of available system memory, which includes the amount of available physical memory and the amount of available swap file space on the computer.

PhysicalMemory

Scalar structure with the fields Available and Total.

  • The value of the Available field is the amount of available physical memory (RAM) on the computer. You can use this value as a measure of how much data you can access without the need for the paging file on disk.

  • The value of the Total field is the amount of total physical memory on the computer.

Limitations

  • The memory function is available only on Microsoft® Windows® platforms.

More About

collapse all

Extended Capabilities

expand all

Version History

Introduced in R2008a