- #1
Haorong Wu
- 413
- 89
- TL;DR Summary
- How to free memory that is allocated but is not used currently in Matlab?
Hi. I am using Matlab to solve ODEs. I use ode45 in a for loop since solving the ODEs in a single ode45 function yielding an error of "out of memory".
However, after the loop has run many times for several hours, the memory will still be full and the program will become slower and slower. If I pause the program, then after several minutes, the memory will be free automatically. It seems that Matlab will not free the memory allocated before unless I pause the program.
So I am trying to find a way to free that memory in the process.
I used the "pack" function. But it can only be used from the command line, and can not be written in a program. Also, I try to use a memory-optimizing app, but it failed when the program is running.
Now I am thinking of using the command "memory" to acquire current memory information and pause the program if not enough memory is available. I am not sure whether this will work or not. I will wait and see.
Are there other methods?
Thanks!
However, after the loop has run many times for several hours, the memory will still be full and the program will become slower and slower. If I pause the program, then after several minutes, the memory will be free automatically. It seems that Matlab will not free the memory allocated before unless I pause the program.
So I am trying to find a way to free that memory in the process.
I used the "pack" function. But it can only be used from the command line, and can not be written in a program. Also, I try to use a memory-optimizing app, but it failed when the program is running.
Now I am thinking of using the command "memory" to acquire current memory information and pause the program if not enough memory is available. I am not sure whether this will work or not. I will wait and see.
Are there other methods?
Thanks!