Zachary Ware <zachary.w...@gmail.com> added the comment:
This looks like a simple reference cycle, as far as I can tell; I don't see an actual refleak. Reproducing using Mark's code from StackOverflow (adjusted): $ ./python.exe -X showrefcount Python 3.9.0a6+ (heads/master-dirty:d10091aa17, May 8 2020, 17:43:51) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> [48551 refs, 15489 blocks] >>> from ctypes import * [53774 refs, 17227 blocks] >>> s = create_string_buffer(1<<30);del s [53832 refs, 17254 blocks] >>> s = create_string_buffer(1<<30);del s [53832 refs, 17255 blocks] >>> s = create_string_buffer(1<<30);del s [53832 refs, 17254 blocks] >>> s = create_string_buffer(1<<30);s = cast(s, c_void_p);del s [53839 refs, 17258 blocks] >>> s = create_string_buffer(1<<30);s = cast(s, c_void_p);del s [53844 refs, 17262 blocks] >>> import gc [54078 refs, 17315 blocks] >>> gc.collect() 13 [54030 refs, 17182 blocks] >>> [54030 refs, 17199 blocks] >>> s = create_string_buffer(1<<30);del s [54077 refs, 17227 blocks] >>> gc.collect() 9 [54030 refs, 17182 blocks] >>> s = create_string_buffer(1<<30);s = cast(s, c_void_p);del s;gc.collect() 11 [54030 refs, 17182 blocks] >>> s = create_string_buffer(1<<30);s = cast(s, c_void_p);del s;gc.collect() 11 [54030 refs, 17182 blocks] I'll freely admit that I'm way out of my depth here, but this doesn't look like a bug as far as I can tell. `ctypes` seems to be creating some cyclic references internally, but a collection clears them right up. ---------- nosy: +zach.ware _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40425> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com