[Python-checkins] cpython (merge 3.5 -> default): Issue #25582: Fixed 100 MB memory leak in test_ctypes.
serhiy.storchaka
python-checkins at python.org
Mon Nov 9 15:34:22 EST 2015
https://hg.python.org/cpython/rev/a6f6d8a6152f
changeset: 99022:a6f6d8a6152f
parent: 99018:a4c4b356a27c
parent: 99021:ad4c6f4af909
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Nov 09 22:33:39 2015 +0200
summary:
Issue #25582: Fixed 100 MB memory leak in test_ctypes.
files:
Lib/ctypes/test/test_pointers.py | 12 +++++++++++-
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
--- a/Lib/ctypes/test/test_pointers.py
+++ b/Lib/ctypes/test/test_pointers.py
@@ -195,9 +195,19 @@
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
--- a/Lib/ctypes/test/test_win32.py
+++ b/Lib/ctypes/test/test_win32.py
@@ -135,5 +135,9 @@
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()
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list