This is somewhat off-topic, but I don’t think you can reasonably rely on the finalizer to delete the object. In my experience these objects tend to live in memory for a lot longer than you expect because the Julia GC doesn’t know how large they are.
Therefore I think you should prefer manually managing the memory or avoiding using Ptr{Void}
as a field type. In my case I was able to do the latter, but I think I pay for it by doing extra copies when moving data between Julia and C++.
See for reference
Updating this thread now that I’ve figured out what the problem was. Hopefully this helps somebody coming from Google (hi!).
The problem is not at all related to the code structure I outlined in the previous post, but rather the details of the long_computation function are at fault.
Essentially I wrote a wrapper around a C++ library that does things like
type MyCxxType
ptr :: Ptr{Void}
end
function MyCxxType()
ptr = ccall( ... ) # new CxxType()
output = MyCxxType(ptr)
finaliz…
opened 02:28AM - 13 Jun 15 UTC
closed 12:15AM - 10 Jul 15 UTC
sparse
After reading [this post](https://groups.google.com/forum/#!topic/julia-users/4a… SWQTJPFKc) on the mailing list I started bisecting and found that after https://github.com/JuliaLang/julia/commit/2ecb6d5c58e8 the function `cholfact` does no longer free its memory after use. It is a quite big commit but my guess is that some "finalizer command" is not sent to cholmod for it to release its internal memory.
The test script I used is the same one as in the mailing list:
``` julia
function f(n)
A = speye(n)
fact = cholfact(A)
for i=1:1000
fact = cholfact(A)
end
end
```
The memory allocations are not seen by `@time` so some external program like `htop` can be used. This is the status after running the test script a couple of times for `n = 10_000`:
![screenshot from 2015-06-13 04 25 59](https://cloud.githubusercontent.com/assets/1282691/8142661/52f5a70c-1184-11e5-88d6-d7e9ccaccaf6.png)
The memory is not reclaimed until Julia is exited.
CC @andreasnoack