Matlab memory use increases every time I run my script
12 ビュー (過去 30 日間)
古いコメントを表示
Whenever I run my script MATLAB.exe increases in size by several hundred Mbytes, as reported by the Windows resource monitor. After a few trials my memory is filled.
How do I fix this? Currently I remedy this by closing and restarting Matlab.
I am running Matlab using a 64 bit version of Windows 7 with 8GB of RAM.
0 件のコメント
回答 (1 件)
Jan
2016 年 11 月 17 日
Without seeing any details, it is impossible to guess, what's going on. There is no general "do not let Matlab waste memory" flag. Perhaps your script stores more and more values in a growing array? If you in addition forgot to pre-allocate it (search for the term in this forum in case of doubts), the memory consumption is a problem of your script and not of Matlab. A whos and a feature memstats should reveal some details.
Do you use any C-Mex scripts provided by users?
3 件のコメント
Steven Lord
2016 年 11 月 17 日
Show us a SMALL segment of code with which you can reproduce the problem and a SMALL sample of data needed to run that code and we may be able to offer much more specific suggestions.
Jan
2016 年 11 月 21 日
Matlab does release memory automatically, when it is not used anymore. And the OS will clean this memory automatically as soon as it finds the time to do this. A proper pre-allocation (better reserve too much memory then letting an array grow) reduces the need to cleanup memory and is important for the performance.
The memory might be occupied by persistent variables or by a huge number of objects in a figure. So please show us some code, which reproduces the problem. Otherwise an explicit suggestion would be based on guessing.
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!