8000 GLFW callbacks not released · Issue #821 · dotnet/Silk.NET · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
GLFW callbacks not released #821
Closed
Closed
@krmr

Description

@krmr

Summary

After closing a GLFW rendering window GLFW ande some referenced objects remain in memory.

Steps to reproduce

  • Platform: Desktop
  • Framework Version: .NET 5
  • API: OpenGL
  1. Run the code from 'Tutorial 1.1 - Hello Window' in the debugger with a breakpoint on the closing brace of Main.
  2. Once the breakpoint is hit create a memory snapshot and open it.
  3. Inspecting the snapshot shows that the callbacks created in GlfwWindow (e.g. WindowCloseCallback or FramebufferSizeCallback) are still in memory.

Comments

From some debugging I think this might be due to those callbacks being lambdas/closures referenced by GlfwWindow.

Also I am not sure if GlfwWindow.UnregisterCallbacks acutally unregisters all of them. At least GCUtility.Unpin does not find the corresponding handles. To me it looks like only the most recent one is actually pinned due using PinMode.UntilNextCall.

I could get rid of the objects locally by making two changes:

  1. In Glfw change all Callbacks from [PinObject(PinMode.UntilNextCall)] to [PinObject]
  2. In GlfwWindow.UnregisterCallbacks after calling Unpin also set the fields to null

Since I do not understand this code well enough I doubt this is the right thing to do. The first step was because I noticed that GCUtilities.Pins contained only a single handle at all which causes Unpin not to find the callbacks in there.

Background

I have a service for rendering 3D scenes to images. This creates a new window for each request and I found that the memory usage keeps growing over time. Doing some memory profiling brought up that those Glfw* objects remain in memory.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0