Fix a memory leak in SharedMemory on Windows, i.e. the main Class from Pythons 'multiprocessing.shared_memory' module:
If 2 or more shared memory objects are created the .unlink() method fails (on windows) so that the memory is not released until all associated process finish (i.e. memory is potentially consumed continuously and not released):
- https://stackoverflow.com/questions/65968882/unlink-does-not-work-in-pythons-shared-memory-on-windows
- python/cpython#20684
- https://bugs.python.org/issue40882
- python/cpython#85059
- Download and run 'shared_memory_test.py'.
- If the test is failed then uncomment 'import shm_win-patch' on line 1 and re-run.
- This should fix the memory leak.
This is a potentially fragile solution and we may need to update 'shm_win_patch.py' peroidically to keep up with the 'shared_memory.py' repository:
At some point the real fix should be updated in 'shared_memory.py' at which point this patch will no longer be needed...
Thanks to https://github.com/nhthayer for throwing this together