aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Memory/WindowsShared/PlaceholderManager.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.Memory/WindowsShared/PlaceholderManager.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.Memory/WindowsShared/PlaceholderManager.cs')
-rw-r--r--Ryujinx.Memory/WindowsShared/PlaceholderManager.cs15
1 files changed, 10 insertions, 5 deletions
diff --git a/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs b/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs
index b0b3bf05..d465f341 100644
--- a/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs
+++ b/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
+using System.Runtime.Versioning;
using System.Threading;
namespace Ryujinx.Memory.WindowsShared
@@ -7,6 +8,7 @@ namespace Ryujinx.Memory.WindowsShared
/// <summary>
/// Windows memory placeholder manager.
/// </summary>
+ [SupportedOSPlatform("windows")]
class PlaceholderManager
{
private const ulong MinimumPageSize = 0x1000;
@@ -203,7 +205,7 @@ namespace Ryujinx.Memory.WindowsShared
ulong endAddress = startAddress + unmapSize;
var overlaps = Array.Empty<IntervalTreeNode<ulong, ulong>>();
- int count = 0;
+ int count;
lock (_mappings)
{
@@ -226,8 +228,11 @@ namespace Ryujinx.Memory.WindowsShared
ulong overlapEnd = overlap.End;
ulong overlapValue = overlap.Value;
- _mappings.Remove(overlap);
- _mappings.Add(overlapStart, overlapEnd, ulong.MaxValue);
+ lock (_mappings)
+ {
+ _mappings.Remove(overlap);
+ _mappings.Add(overlapStart, overlapEnd, ulong.MaxValue);
+ }
bool overlapStartsBefore = overlapStart < startAddress;
bool overlapEndsAfter = overlapEnd > endAddress;
@@ -364,7 +369,7 @@ namespace Ryujinx.Memory.WindowsShared
ulong endAddress = reprotectAddress + reprotectSize;
var overlaps = Array.Empty<IntervalTreeNode<ulong, ulong>>();
- int count = 0;
+ int count;
lock (_mappings)
{
@@ -534,7 +539,7 @@ namespace Ryujinx.Memory.WindowsShared
{
ulong endAddress = address + size;
var overlaps = Array.Empty<IntervalTreeNode<ulong, MemoryPermission>>();
- int count = 0;
+ int count;
lock (_protections)
{