Matlab memory use increases every time I run my script
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Jan
le 17 Nov 2016
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 commentaires
Steven Lord
le 17 Nov 2016
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
le 21 Nov 2016
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.
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!