diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-09 20:32:23 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-09 20:32:23 (GMT) |
commit | 82639816df9e2d06fe47687983c13e535895649d (patch) | |
tree | 96e0df6d46cf1ea6b446171cee04c701e45091b7 /Lib | |
parent | 850be0fb184ee1a5a42df5ecc1b8b62c433b1c6e (diff) | |
parent | b63902a74834e3e7d15356ff60e017ee6efba2a7 (diff) | |
download | cpython-82639816df9e2d06fe47687983c13e535895649d.zip cpython-82639816df9e2d06fe47687983c13e535895649d.tar.gz cpython-82639816df9e2d06fe47687983c13e535895649d.tar.bz2 |
Issue #25582: Fixed 100 MB memory leak in test_ctypes.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ctypes/test/test_pointers.py | 12 | ||||
-rw-r--r-- | Lib/ctypes/test/test_win32.py | 4 |
2 files changed, 15 insertions, 1 deletions
diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/ctypes/test/test_pointers.py index 40738f7..225b9d1 100644 --- a/Lib/ctypes/test/test_pointers.py +++ b/Lib/ctypes/test/test_pointers.py @@ -195,9 +195,19 @@ class PointersTestCase(unittest.TestCase): LargeNamedType = type('T' * 2 ** 25, (Structure,), {}) self.assertTrue(POINTER(LargeNamedType)) + # to not leak references, we must clean _pointer_type_cache + from ctypes import _pointer_type_cache + del _pointer_type_cache[LargeNamedType] + def test_pointer_type_str_name(self): large_string = 'T' * 2 ** 25 - self.assertTrue(POINTER(large_string)) + P = POINTER(large_string) + self.assertTrue(P) + + # to not leak references, we must clean _pointer_type_cache + from ctypes import _pointer_type_cache + del _pointer_type_cache[id(P)] + if __name__ == '__main__': unittest.main() diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py index 5867b05..da16240 100644 --- a/Lib/ctypes/test/test_win32.py +++ b/Lib/ctypes/test/test_win32.py @@ -135,5 +135,9 @@ class Structures(unittest.TestCase): self.assertEqual(ret.top, top.value) self.assertEqual(ret.bottom, bottom.value) + # to not leak references, we must clean _pointer_type_cache + from ctypes import _pointer_type_cache + del _pointer_type_cache[RECT] + if __name__ == '__main__': unittest.main() |