Every time I run NDsolve
it uses some memory that I am not able to free later.
The following is an example code based on the spring equation (Hooke's law) that increases memory usage by 280 bytes each iteration.
$HistoryLength = 0;
tlimit = 1;
x0 = 1;
m = 1;
k = 1;
Do[
memory1 = MemoryInUse[];
Print[memory1];
sol = NDSolve[{x''[t] == -k/m*x[t], x[0] == x0, x'[0] == 0}, x, {t, 0., tlimit}];
Clear[sol];
ClearSystemCache[];
memory2 = MemoryInUse[];
Print[memory2];
, {x0, {0, 1, 2, 3}}]
memory2 - memory1
As you can see I have already tried with $HistoryLenght = 0, ClearSystemCache[], Clear[sol]
Does anyone know how to free that memory again so that the memory usage will not increase at every iteration?
Comments
Post a Comment