How much Mac memory can Matlab utilize?

21 次查看(过去 30 天)
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 个评论
John D'Errico
John D'Errico 2024-1-16
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.

请先登录,再进行评论。

回答(2 个)

Walter Roberson
Walter Roberson 2024-1-16
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 2024-1-16
Try this:
>> memory
in the command window.

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by