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.
[
returns user-focused information about memory in userview
,systemview
] = memoryuserview
and
system-focused information about memory in systemview
.
Examples
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
User-focused memory information, returned as a structure.
userview
has three fields:
Field Name | Field 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:
To see how many array elements this number
represents, divide by the number of bytes in the array class. For example,
for a |
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:
|
MemUsedMATLAB | Total system memory reserved for the MATLAB process. |
System-focused memory information, returned as a structure.
systemview
has three fields:
Field Name | Field Value |
---|---|
VirtualAddressSpace | Scalar structure with the fields
|
SystemMemory | Scalar structure with the field |
PhysicalMemory | Scalar structure with the fields
|
Limitations
The
memory
function is available only on Microsoft® Windows® platforms.
More About
memory
displays these values in the Command Window.
All reported values are of type double
and are expressed in bytes.
Maximum possible array
: Size of the largest contiguous free memory blockMemory available for all arrays
: Total memory available to hold dataMemory used by MATLAB
: Total system memory reserved for the MATLAB processPhysical Memory (RAM)
: Total physical memory (RAM) on the computer
In addition to the values, MATLAB also might display this statement:
* Limited by System Memory (physical + swap file) available.
If the statement applies to
Maximum possible array
, then there is insufficient system memory to allow for the mapping of all virtual addresses in the largest available block of the MATLAB process.If the statement applies to
Memory available for all arrays
, then there is insufficient system memory to allow for the mapping of all available virtual addresses in the MATLAB process.
MATLAB computes the size of Memory used by MATLAB
by walking the
MATLAB process memory structures and summing all of the sections that have physical
storage allocated in memory or in the paging file on disk.
The actual memory information might be different from the information captured when the function was called. Results depend on your computer hardware and the time-varying load on your computer.
Reserved addresses are set aside in the process virtual address space
for some specific future use. These reserved addresses reduce the size of Memory
available for all arrays
and can reduce the size of the current or future value
of Maximum possible array
.
For example, at MATLAB startup, part of the MATLAB virtual address space is reserved by the Java® Virtual Machine (JVM®) and cannot be used for storing MATLAB arrays.
Extended Capabilities
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2008a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)