From a906f2071cbe4caf53c697bcb7dfa91e3e7dcfae Mon Sep 17 00:00:00 2001 From: Thog Date: Thu, 6 Feb 2020 12:38:24 +0100 Subject: Fix a crash when closing the main UI (#904) * Fix a crash when closing the main Ui Also make sure to dispose the OpenAL context to not leak memory when unloading the emulation context. * Improve keys and 'game already running' dialogs * Make sure to dispose the page table and ThreadContext Less memory leaks! * Fix tests * Address gdk's comments --- Ryujinx.HLE/HOS/Horizon.cs | 5 ++++- Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs | 5 +++++ Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'Ryujinx.HLE/HOS') diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs index a2bff7f6..f8d2ed71 100644 --- a/Ryujinx.HLE/HOS/Horizon.cs +++ b/Ryujinx.HLE/HOS/Horizon.cs @@ -107,6 +107,7 @@ namespace Ryujinx.HLE.HOS public Keyset KeySet => Device.FileSystem.KeySet; private bool _hasStarted; + private bool _isDisposed; public BlitStruct ControlData { get; set; } @@ -740,8 +741,10 @@ namespace Ryujinx.HLE.HOS protected virtual void Dispose(bool disposing) { - if (disposing) + if (!_isDisposed && disposing) { + _isDisposed = true; + KProcess terminationProcess = new KProcess(this); KThread terminationThread = new KThread(this); diff --git a/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs b/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs index f987c83c..7807ec5a 100644 --- a/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs +++ b/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs @@ -1131,5 +1131,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process { throw new UndefinedInstructionException(e.Address, e.OpCode); } + + protected override void Destroy() + { + CpuMemory.Dispose(); + } } } \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs b/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs index c4bd781d..53eb5bdc 100644 --- a/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs +++ b/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs @@ -1141,6 +1141,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading { Owner.Translator.Execute(Context, entrypoint); + Context.Dispose(); + ThreadExit(); } -- cgit v1.2.3