Closed lucasp0927 closed 8 years ago
See #29?
And #49.
The problem is that under the hood in both cases NVector
s are created from Julia Array
s, but the memory is not released. This is addressed in #29, which is unfortunately a bit outdated.
If I were to update the changes from #29 to the current version what would I need to do? Would it be faster to attempt to merge (by hand) the code into a new fork, or to start over? I think the complexity level is a bit higher than what I have looked at so far, but I I'm considering giving it a shot. Would really like if I could use the solver for some uncertainty quantification without it eating all of my memory.
That mainly depends on how well you know git. You can try using git to merge #29 into master to see how many conflicts there are. The code hasn't changed that much since then, so it may not be too bad.
@christianhaargaard : I think most of the changes in #29 shouldn't be affected by the recent changes in Sundials.jl - Merging shouldn't be a problem. You can also just copy the essentials from #29 and start a new PR. There are some comments from Steven that should be taken into account though.
@tshort and @acroy : I tried merging the entire acroy/types fork, but that doesn't seem viable. All of the bindings are using the @c macro, whereas the main repository has the ccall function written out completely. I will try and see if I have better luck merging only the corresponding commits, and then report back.
Putting this together is a mess when you have as little experience and overview as I do. However I did manage to get the simple cvode-interface to free up memory after each run. The code is so dirty however that I would never invite it into my house. I'm hoping I can get some time to look it through and better understand the structure, and possible clean it up. If someone should be in dire need of running the solver without eating up all the memory, my code is available here (though I'm not proud to share it): https://github.com/christianhaargaard/Sundials.jl/ It's in the master branch.
Ah so I suppose thats why my program crashed with
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
signal (6): Aborted
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
terminate called recursively
I will try ur fix @christianhaargaard :)
So the memory allocation is a big topic in Sundials :O.
The problem was already reported in #24, suggesting manual cleanup with CVodeFree
(implemented by now) and N_VDestroy_Serial
(not yet implemented).
Unfortunately #29 seems to have fallen asleep :(
Thus I basically reimplemented the changes from #26 for cvode
(not the other solvers) based on the current master: https://github.com/axsk/Sundials.jl/tree/axsk/hotfixmemleak
Should I open a PR to it? I think a part-fix is still better then nothing (considering there seemingly is nothing else happening about this right now)
The non-progress on #29 is my fault :-(, but right now I don't have the time to finish it. As a first step one would need to rebase/port it against the current master, which shouldn't be hard. Then one could fix the loose ends ...
When I suggested #26, the others argued one should do it properly and I agree with that. If you happen to have some time, maybe you could try to port #29 to the current master and then we continue from there? However, if you want to revive #26 I would suggest to fix the other solvers too.
@acroy What are the loose ends of the #29 (besides the need to rebase)?
Closing due to #67.
I'm using sundials to do some trajectory simulations. I noticed there's memory leak in both cvode() simple function and CVode(). The following code is able to reproduce the problem. Both mycvode() and Sundials.cvode() experience this issue.