FacticiusVir / SharpVk

C# Bindings for the Vulkan API & SPIR-V
MIT License
147 stars 18 forks source link

Leaking DLL handles #58

Open Y-Less opened 4 years ago

Y-Less commented 4 years ago

There's no cleanup in SharpVk.Interop.NativeLibrary. A standard setup will call SharpVk.Instance.EnumerateExtensionProperties, SharpVk.Instance.EnumerateVersion, SharpVk.Instance.Create and probably more. All of these create new instances of NativeLibrary, all getting a handle to vulkan-1.dll, but none of them cleaning it up again.

FacticiusVir commented 4 years ago

NativeLibrary was always a bit of a hack to handle the different DLL names on different OSes; the helper methods on Instance that create it were written on the assumption you'd only call them a small number of times when the app starts. There are overloads that accept a CommandCache instance (which wraps NativeLibrary), so you can create it once and re-use it; but now that .NET Core 3 has improved DLL mapping I need to revisit how that whole section works.