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

Missing deallocation of context object #15

Open
athas opened this issue Jul 20, 2020 · 1 comment
Open

Missing deallocation of context object #15

athas opened this issue Jul 20, 2020 · 1 comment

Comments

@athas
Copy link
Contributor

athas commented Jul 20, 2020

The implementation of FutharkContext does not at any point call
futhark_context_free() or futhark_context_config_free(). This
means that the actual Futhark context object is not freed when the
FutharkContext Rust object is destroyed. GPU resources may thus be
leaked until the process ends entirely and they are reclaimed by the
operating system.

I recommend adding an implementation of the Drop trait for
FutharkContext, which should call futhark_context_free() and
futhark_context_config_free() (in that order). If this is done,
then the implementation of the Copy and Clone
traits should probably be removed.

@Erk-
Copy link
Owner

Erk- commented Oct 15, 2020

I have a few ideas on how to resolve this. One would be to use Arcs to refer to the context from other objects and first free the Context when there are no objects that refer to it.

Another way would be that onjects have Weak pointers to the Context which have a strong Arc this way the context can get freed when there are still objects alive. We could then have a new error that can happen when the context have been freed.

And finally there is also the original idea of using borrowed references in objects, which will work, but may not be nice to work with.

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

Successfully merging a pull request may close this issue.

2 participants