diff options
| author | Zackery Spytz <zspytz@gmail.com> | 2022-11-25 17:39:48 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-25 17:39:48 (GMT) |
| commit | 85c128e34daec7625b74746e127afa25888ccde1 (patch) | |
| tree | 81f9e08d696f6e61ecab4863e5cf345b9ee56906 /Lib/multiprocessing/shared_memory.py | |
| parent | 8749121b07f48994ea47f2e7ff75fb13c13953f6 (diff) | |
| download | cpython-85c128e34daec7625b74746e127afa25888ccde1.zip cpython-85c128e34daec7625b74746e127afa25888ccde1.tar.gz cpython-85c128e34daec7625b74746e127afa25888ccde1.tar.bz2 | |
bpo-40882: Fix a memory leak in SharedMemory on Windows (GH-20684)
In multiprocessing.shared_memory.SharedMemory(), the temporary view
returned by MapViewOfFile() should be unmapped when it is no longer
needed.
Diffstat (limited to 'Lib/multiprocessing/shared_memory.py')
| -rw-r--r-- | Lib/multiprocessing/shared_memory.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/multiprocessing/shared_memory.py b/Lib/multiprocessing/shared_memory.py index 881f200..9a1e5aa 100644 --- a/Lib/multiprocessing/shared_memory.py +++ b/Lib/multiprocessing/shared_memory.py @@ -173,7 +173,10 @@ class SharedMemory: ) finally: _winapi.CloseHandle(h_map) - size = _winapi.VirtualQuerySize(p_buf) + try: + size = _winapi.VirtualQuerySize(p_buf) + finally: + _winapi.UnmapViewOfFile(p_buf) self._mmap = mmap.mmap(-1, size, tagname=name) self._size = size |
