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!