File Exchange

image thumbnail

memoryInfo()

version 1.0.0.0 (3.42 KB) by Sviatoslav Danylenko
Cross-platform memory usage information

2 Downloads

Updated 18 Feb 2014

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Returns a struct with the information about memory usage in kB. For example:
>> printR(memoryInfo)
struct():
total: 3932392
free: 156216
used: 3776176
cache: 1154900
usedMatlab: 588220
swap: [1x1 struct]
struct().swap:
total: 4095696
free: 3294648
used: 801048
usedMatlab: 7488

Note: MATLAB swap usage calculation on Windows was not implemented. You can get only swapusage for all applications running on the machine.

Cite As

Sviatoslav Danylenko (2021). memoryInfo() (https://www.mathworks.com/matlabcentral/fileexchange/45598-memoryinfo), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)

Daniel Dolan

This is a great idea, but it doesn't work on my Mac. No errors are generated, but the structure fields all come back as zero or nan. Digging into the function, I can see that the undocumented "feature" command returns the correct PID, but the subsequent awk call cannot open the file /proc/(PID)/status.

I'm running MATLAB2019a on OS X High Sierra.

Francisco Ramírez

Nice... it works with my Ubuntu 18.04 since the built-in MATLAB function "memory" doesn't work

Emmanuel Farhi

Excellent, and it does work on non Windows systems. Thanks.

Johan Winges

MATLAB Release Compatibility
Created with R2008b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!