Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sundials problem memory is not garbage collected #49

Closed
ikirill opened this issue Feb 26, 2015 · 3 comments
Closed

Sundials problem memory is not garbage collected #49

ikirill opened this issue Feb 26, 2015 · 3 comments

Comments

@ikirill
Copy link
Contributor

ikirill commented Feb 26, 2015

Ideally, there should be a garbage-collected wrapper looking something like this:

type CVmem
  handle :: Ptr{Void}
  function CVmem(lmm::Cint, iter::Cint)
    mem = new(CVodeCreate(lmm, iter))
    mem.handle == C_NULL && error("CVodeCreate failed")
    finalizer(mem, CVodeFree)
    mem
  end
end

convert(::Type{Ptr{Void}}, mem::CVmem) = mem.handle

CVodeFree(mem::CVmem) = ccall((:CVodeFree, Sundials.libsundials_cvodes), Void, (Ptr{Ptr{Void}},), &mem)

Of course, the garbage collector won't always collect the memory aggressively if Sundials uses a lot of it, but it is much more "julia-like" to try to collect these pointers than to expect the user to call create/free pairs.

@acroy
Copy link
Contributor

acroy commented Feb 26, 2015

See #29. If you happen to have some time it would be great if you could take care of finishing #29. Shouldn't be much left to do ...

@axsk
Copy link
Contributor

axsk commented Jun 8, 2016

Maybe one should close this issue, since its all in #29?

@acroy
Copy link
Contributor

acroy commented Jun 16, 2016

The simplified interface now uses CVodeFree et al to free memory. The finializer idea is covered in #29.

@acroy acroy closed this as completed Jun 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants