Skip to content

Invoke finalizers on garbage collection  #6

@airstruck

Description

@airstruck

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions