[New-bugs-announce] [issue3329] API for setting the memory allocator used by Python

Jukka Laurila report at bugs.python.org
Wed Jul 9 21:48:53 CEST 2008


New submission from Jukka Laurila <jukka.p.laurila at nokia.com>:

Currently Python always uses the C library malloc/realloc/free as the
underlying mechanism for requesting memory from the OS, but especially
on memory-limited platforms it is often desirable to be able to override
the allocator and to redirect all Python's allocations to use a special
heap. This will make it possible to free memory back to the operating
system without restarting the process, and to reduce fragmentation by
separating Python's allocations from the rest of the program.

The proposal is to make it possible to set the allocator used by the
Python interpreter by calling the following function before Py_Initialize():

void Py_SetAllocator(void* (*alloc)(size_t), void* (*realloc)(void*,
size_t), void (*free)(void*))

Direct function calls to malloc/realloc/free in obmalloc.c must be
replaced with calls through the function pointers set through this
function. By default these would of course point to the C stdlib
malloc/realloc/free.

----------
components: Interpreter Core
messages: 69482
nosy: jlaurila
severity: normal
status: open
title: API for setting the memory allocator used by Python
type: feature request
versions: Python 2.6, Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3329>
_______________________________________


More information about the New-bugs-announce mailing list