How to increase the memory that MATLAB uses?
조회 수: 493 (최근 30일)
이전 댓글 표시
I have 19 GB of memory available for running Matlab. However, Matlab is only using 1 GB of memory. This is adversely affecting my ability to run my code. How do I increase the amount of memory that Matlab is using?
댓글 수: 0
채택된 답변
OCDER
2018년 5월 18일
편집: Walter Roberson
2018년 5월 18일
This was answered here:
Matlab will use more memory if you need more memory. It's not capped at 1 GB. To test this, try:
>> memory
>> a = rand(20000);
>> memory
You'll notice that the memory usage by Matlab increases
Is there an error like "Out of Memory"? If yes, then it's indeed a memory issue that needs to be fixed by changing the way your code loads large data. If not, then it's not a memory issue but slow algorithm issue. These articles can help:
To help you determine the code bottleneck, use the profile: https://www.mathworks.com/help/matlab/ref/profile.html
댓글 수: 1
Babak
2024년 2월 14일
편집: Babak
2024년 2월 14일
@Walter Roberson My plots are very laggy.
There are 8 figures with 50 curves each and when I go to "Plot Browser" mode and uncheck "Edit Plot" the zoom in/out/drag and restore view become very laggy. How can I improve memory usage or plot algorithm?
추가 답변 (3개)
April Bryan
2018년 5월 18일
댓글 수: 4
Hoang-Le Tran
2023년 12월 11일
If I am running on a system that is being used for other memory-intensive purposes, is there a way to reserve memory specifically for Matlab such that there is no competition?
Walter Roberson
2023년 12월 11일
You just might be able to do that with RTLinux (Real Time Linux), but as far as I know it cannot be done with regular Linux.
For modern versions of MacOS, the most you can do is increase the process priority using the renice utility. Sufficiently old versions of MacOS had other ways available as well.
For Windows, as far as I know the most you can do is increase hte process priority; https://www.auslogics.com/en/articles/change-priority-of-win10-process-with-command-line/
April Bryan
2018년 5월 21일
댓글 수: 1
OCDER
2018년 5월 21일
편집: OCDER
2018년 5월 21일
The memory >> rand >> memory command is only there to show you that Matlab changes it's memory usage dynamically, depending how much memory you need. And how are you removing the memory cap? Is doing a = rand(20000) making your code faster? That is indeed odd, as a = rand(20000) decreases your available memory...
Sometimes the initialization of Matlab is slow, and running a script the first time is slow. Is it still slow when you rerun the same script? Maybe this Q&A is relevant:
Have you tried the profile function to see what is causing your program to run slowly?
%Try this example, directly from "help profile" command
profile on %Begin tracking code performance
plot(magic(35)) %Replace this line with your code summon that's slow
profile viewer %View time to run each line of code. Which one is slow?
Try the profiler first and locate the lines of code that are taking a long time. Without this info and code, it's hard to debug.
Last, use the Comments section instead of the Answer section to respond.
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!