Matlab memory use increases every time I run my script

14 visualizaciones (últimos 30 días)
Mike Enns
Mike Enns el 17 de Nov. de 2016
Comentada: Jan el 21 de Nov. de 2016
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.

Respuestas (1)

Jan
Jan el 17 de Nov. de 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 comentarios
Steven Lord
Steven Lord el 17 de Nov. de 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
Jan el 21 de Nov. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by