From d90a2ca0dc3d354e743e5a77c38bb4fc4926451e Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Thu, 2 Jan 2025 17:41:01 -0500 Subject: [PATCH] Try to avoid leaks in the SoundEffect FAudio context --- src/FNAPlatform/SDL2_FNAPlatform.cs | 2 ++ src/FNAPlatform/SDL3_FNAPlatform.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/FNAPlatform/SDL2_FNAPlatform.cs b/src/FNAPlatform/SDL2_FNAPlatform.cs index 623610b2..df1da8f8 100644 --- a/src/FNAPlatform/SDL2_FNAPlatform.cs +++ b/src/FNAPlatform/SDL2_FNAPlatform.cs @@ -379,6 +379,8 @@ public static void ProgramExit(object sender, EventArgs e) if (SoundEffect.FAudioContext.Context != null) { + GC.Collect(); // Desperate last bid to collect SoundEffectInstances + SoundEffect.FAudioContext.Context.Dispose(); } Media.MediaPlayer.DisposeIfNecessary(); diff --git a/src/FNAPlatform/SDL3_FNAPlatform.cs b/src/FNAPlatform/SDL3_FNAPlatform.cs index 1e764bdb..657ad676 100644 --- a/src/FNAPlatform/SDL3_FNAPlatform.cs +++ b/src/FNAPlatform/SDL3_FNAPlatform.cs @@ -284,6 +284,8 @@ public static void ProgramExit(object sender, EventArgs e) if (SoundEffect.FAudioContext.Context != null) { + GC.Collect(); // Desperate last bid to collect SoundEffectInstances + SoundEffect.FAudioContext.Context.Dispose(); } Media.MediaPlayer.DisposeIfNecessary();