The "sys.getallocatedblocks()" function needs some CPython specific unit tests
in test_sys.
And the name should be getallocatedblocks(), not getallocedblocks()
Other comments are fairly minor - one for consistency with _Py_GetRefTotal(),
the other to make it more obvious to a human reader that the block accounting is
correct when reading the source code.
http://bugs.python.org/review/13390/diff/3633/11366
File Include/objimpl.h (right):
http://bugs.python.org/review/13390/diff/3633/11366#newcode102
Include/objimpl.h:102: PyAPI_DATA(Py_ssize_t) _Py_AllocedBlocks;
Do you have any particular reason for only exposing the data value directly
instead of hiding it behind a function the way _Py_GetRefTotal() does? Either
*works*, of course, but why be inconsistent?
http://bugs.python.org/review/13390/diff/3633/11369
File Objects/obmalloc.c (right):
http://bugs.python.org/review/13390/diff/3633/11369#newcode909
Objects/obmalloc.c:909: return (void *)bp;
To guarantee correct updating of the number of allocated blocks, I suggest
adding an "assert(bp != NULL);" here.
Issue 13390: Hunt memory allocations in addition to reference leaks
Created 1 year, 6 months ago by AntoinePitrou
Modified 5 months, 2 weeks ago
Reviewers: Nick Coghlan
Base URL: None
Comments: 2