Fix shared memory leak on Windows #3319
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes the following issues:
UnmapView
was updating the tree outside of the lock, which makes the code not thread safe, it could lead to corruption of the tree if two threads tried to unmap memory at the same time.ArmProcessContext
was disposed before the session object was disposed. This is because the memory manager instance is set to null. This was fixed by storing the memory manager instance on the RO object.The first 3 issues were validated with the following test (which is not included as it allocates 1GB of memory in the loop to ensure there's no memory leak, and I think this might be too high for a general test):
And the last fix was validated on Super Mario 64 from Super Mario 3D All Stars.
All these issues were introduced on #2954, although its possible that the memory leak already existed (I did not test if versions prior to that leaked when stopping and restarting emulation).
Testing is welcome as always.