mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-24 00:46:04 +00:00
Dispose Counters before they hit the finalizer queue
This commit is contained in:
parent
11130f7826
commit
28f43f5622
1 changed files with 10 additions and 6 deletions
|
@ -28,7 +28,7 @@ namespace ARMeilleure.Translation
|
|||
private readonly IMemoryManager _memory;
|
||||
|
||||
private readonly ConcurrentDictionary<ulong, TranslatedFunction> _funcs;
|
||||
private readonly ConcurrentQueue<KeyValuePair<ulong, IntPtr>> _oldFuncs;
|
||||
private readonly ConcurrentQueue<KeyValuePair<ulong, TranslatedFunction>> _oldFuncs;
|
||||
|
||||
private readonly ConcurrentDictionary<ulong, object> _backgroundSet;
|
||||
private readonly ConcurrentStack<RejitRequest> _backgroundStack;
|
||||
|
@ -50,7 +50,7 @@ namespace ARMeilleure.Translation
|
|||
_memory = memory;
|
||||
|
||||
_funcs = new ConcurrentDictionary<ulong, TranslatedFunction>();
|
||||
_oldFuncs = new ConcurrentQueue<KeyValuePair<ulong, IntPtr>>();
|
||||
_oldFuncs = new ConcurrentQueue<KeyValuePair<ulong, TranslatedFunction>>();
|
||||
|
||||
_backgroundSet = new ConcurrentDictionary<ulong, object>();
|
||||
_backgroundStack = new ConcurrentStack<RejitRequest>();
|
||||
|
@ -457,7 +457,7 @@ namespace ARMeilleure.Translation
|
|||
|
||||
private void EnqueueForDeletion(ulong guestAddress, TranslatedFunction func)
|
||||
{
|
||||
_oldFuncs.Enqueue(new KeyValuePair<ulong, IntPtr>(guestAddress, func.FuncPtr));
|
||||
_oldFuncs.Enqueue(new(guestAddress, func));
|
||||
}
|
||||
|
||||
private void ClearJitCache()
|
||||
|
@ -465,16 +465,20 @@ namespace ARMeilleure.Translation
|
|||
// Ensure no attempt will be made to compile new functions due to rejit.
|
||||
ClearRejitQueue(allowRequeue: false);
|
||||
|
||||
foreach (var kv in _funcs)
|
||||
foreach (var func in _funcs.Values)
|
||||
{
|
||||
JitCache.Unmap(kv.Value.FuncPtr);
|
||||
JitCache.Unmap(func.FuncPtr);
|
||||
|
||||
func.CallCounter?.Dispose();
|
||||
}
|
||||
|
||||
_funcs.Clear();
|
||||
|
||||
while (_oldFuncs.TryDequeue(out var kv))
|
||||
{
|
||||
JitCache.Unmap(kv.Value);
|
||||
JitCache.Unmap(kv.Value.FuncPtr);
|
||||
|
||||
kv.Value.CallCounter?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue