aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2022-05-05 14:58:59 -0300
committerGitHub <noreply@github.com>2022-05-05 14:58:59 -0300
commit54deded929203a64555d97424d5bb4b884fff69f (patch)
tree2ae40f9b49e92db844145ddc61444aac2db6381e /Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs
parent39bdf6d41e6cad370f7a10b766d91418c194ead8 (diff)
Fix shared memory leak on Windows (#3319)1.1.116
* Fix shared memory leak on Windows * Fix memory leak caused by RO session disposal not decrementing the memory manager ref count * Fix UnmapViewInternal deadlock * Was not supposed to add those back
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs')
-rw-r--r--Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs12
1 files changed, 8 insertions, 4 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs b/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs
index 0ce65e3a..d986bc41 100644
--- a/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs
+++ b/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs
@@ -30,6 +30,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
private List<NroInfo> _nroInfos;
private KProcess _owner;
+ private IVirtualMemoryManager _ownerMm;
private static Random _random = new Random();
@@ -38,6 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
_nrrInfos = new List<NrrInfo>(MaxNrr);
_nroInfos = new List<NroInfo>(MaxNro);
_owner = null;
+ _ownerMm = null;
}
private ResultCode ParseNrr(out NrrInfo nrrInfo, ServiceCtx context, ulong nrrAddress, ulong nrrSize)
@@ -564,10 +566,12 @@ namespace Ryujinx.HLE.HOS.Services.Ro
return ResultCode.InvalidSession;
}
- _owner = context.Process.HandleTable.GetKProcess(context.Request.HandleDesc.ToCopy[0]);
- context.Device.System.KernelContext.Syscall.CloseHandle(context.Request.HandleDesc.ToCopy[0]);
+ int processHandle = context.Request.HandleDesc.ToCopy[0];
+ _owner = context.Process.HandleTable.GetKProcess(processHandle);
+ _ownerMm = _owner?.CpuMemory;
+ context.Device.System.KernelContext.Syscall.CloseHandle(processHandle);
- if (_owner?.CpuMemory is IRefCounted rc)
+ if (_ownerMm is IRefCounted rc)
{
rc.IncrementReferenceCount();
}
@@ -586,7 +590,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
_nroInfos.Clear();
- if (_owner?.CpuMemory is IRefCounted rc)
+ if (_ownerMm is IRefCounted rc)
{
rc.DecrementReferenceCount();
}