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

Invoke finalizers on garbage collection #6

Open
airstruck opened this issue Nov 22, 2015 · 0 comments
Open

Invoke finalizers on garbage collection #6

airstruck opened this issue Nov 22, 2015 · 0 comments

Comments

@airstruck
Copy link

Functions that create something that needs to be destroyed later should probably associate the finalizer with ffi.gc. For example:

function sdl.createTextureFromSurface (...)
    return ffi.gc(sdl.C.SDL_CreateTextureFromSurface(...), sdl.C.SDL_DestroyTexture)
end

This might cause unexpected behavior in certain cases (for example a cursor could get GC'd while still in use), but overall would probably be worth it. I'd be willing to make a PR if there's any interest in this.

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

1 participant