Clear Filters
Clear Filters

How much Mac memory can Matlab utilize?

21 views (last 30 days)
Michael
Michael on 16 Jan 2024
Commented: Walter Roberson on 17 Jan 2024
I have a MacBookPro, with the M2 Max chip, and 96GB of RAM.
I have been shocked that some large memory-intensive computations I have been performing for years do not run much faster on this laptop than on a 10 year old intel iMac with far less memory.
Will Matlab R2023b utilize all free memory on the laptop, or does it adopt some upper limit of the memory it attempts to access?
I also tried testing the iMac versus the M2 Max laptop with a much simpler 'toy' number-crunching code that repeatedly takes the inverse of a 1,000 by 1,000 matrix.
Here is the M2 Max run using R2023B, supposedly a native Apple silicon version of Matlab
>> m=1000; n=1000; tic; for i=1:m, A=randn(n,n); B=inv(A); end, toc
Elapsed time is 36.986920 seconds.
Almost the same as running the same command on a Late 2012 iMac (intel)
>> m=1000; n=1000; tic; for i=1:m, A=randn(n,n); B=inv(A); end, toc
Elapsed time is 38.338430 seconds.
I get a similar lack of speed-up if I set n=2000, and repeatedly invert 2,000 by 2,000 matrices, or even larger matrices. I find this lack of performance increase rather strange.
MB
  1 Comment
John D'Errico
John D'Errico on 16 Jan 2024
Note that 2K by 2K matrices are literally tiny, not stressing the memory you have on that computer in the least.
2000*2000*8/1024^3
ans = 0.0298
so 0.03 gigabytes per matrix. Your computer is laughing at you.

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 16 Jan 2024
Will Matlab R2023b utilize all free memory on the laptop, or does it adopt some upper limit of the memory it attempts to access?
Preferences -> Workspace -> MATLAB Workspace Preferences -> MATLAB array size limit -> [ ] Limit the maximum array size to a percentage of RAM
Untick that so that MATLAB will be willing to request more memory than there is physical memory, which could cause swapping to disk.

Image Analyst
Image Analyst on 16 Jan 2024
Try this:
>> memory
in the command window.

Categories

Find more on Just for fun in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!