diff options
| author | Luke Garland <luke.garland01@gmail.com> | 2022-12-05 12:38:25 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-05 12:38:25 (GMT) |
| commit | 374b0a2aceb378da6a3df9beffe35acd0c11c06d (patch) | |
| tree | 8afa73ec7c7b21e7a87592c82664e9e78337bcbd /Lib/multiprocessing/shared_memory.py | |
| parent | 7f2bcc7aaa7b340f840065f94260884f86ba3165 (diff) | |
| download | cpython-374b0a2aceb378da6a3df9beffe35acd0c11c06d.zip cpython-374b0a2aceb378da6a3df9beffe35acd0c11c06d.tar.gz cpython-374b0a2aceb378da6a3df9beffe35acd0c11c06d.tar.bz2 | |
[3.11] bpo-40882: Fix a memory leak in SharedMemory on Windows (GH-20684) (#99973)
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.
(cherry picked from commit 85c128e34daec7625b74746e127afa25888ccde1)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
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 |
