It is important to understand that the management of the Python heap is performed by the interpreter itself and that the user has no control over it, even if they regularly manipulate object pointers to memory blocks inside that heap. The allocation of heap space for Python objects and other internal buffers is performed on demand by the Python memory manager through the Python/C API functions listed in this document.
-void* PyMem_Malloc(size_t n)
-void* PyMem_Realloc(void *p, size_t n)
-void PyMem_Free(void *p)
for more information open this link.