Can I avoid matlab to allocate too much memory?
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm using Matlab R2014b Version 8.3.0.532 on a Linux server and on a Windows desktop. The server is a very resourceful server (24 core, lots of GB of memory,...). The problem is that the same matlab code needs almost 4GB of memory in my 2core Windows-based desktop and more than 20GB of memory in the server. Since the server is shared with other people and I need to run several simulations in parallel, I would like to know why does Matlab ask for more memory in the server and how can I reduce the allocated memory?
At the beginning I thought that the problem was something related with parfor cicles. I did an attempt substituting all the parfor cicles into for circles in the server but the allocated memory is still almost the same value, maybe 2 or 3 GB less, but still too much compared with the Windows case. I also tried to use the same number of workers in both the computers but the problem still remains.
Where do you think is the problem and how I can solve it? Why does Matlab allocate more memory in the server? Thanks
댓글 수: 0
답변 (3개)
Jan
2015년 6월 4일
If a lot of large variables are created, Matlab requests memory from the operating system. When a variable is deleted, the used memory is not free'd immediately, but the operating system can decide, when this happens. Freeing memory causes the clearing of the contents (at least this happens under Windows), such that this needs processing time. Therefore the OS will offer new memory instead of recycling free'd memory, when there is enough free memory available. In consequence the memory usage of Matlab depends on the other applications also and cannot be measured directly.
A strategy to reduce the memory footprint of the code is to avoid the creation of new large variables. See http://blogs.mathworks.com/loren/2007/03/22/in-place-operations-on-data/
Med Aymane Ahajjam
2019년 10월 23일
Personnaly, when using app designer, i do not use variables to hold big chunks of data, instead I put the functions that would result in these values directly as inputs to the next functions.. It saves LOTS of time!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!