Custom memory manager

Jean Brouwers mrjean1ATcomcastDOTnet at no.spam.net
Thu Nov 18 05:43:38 CET 2004


We have done some experiments with the memory manager in Python 2.3+. 
Not to replace it but to obtain more detailed and accurate statistics
for the memory usage.

One thing to keep in in mind is that not all memory in a Python
application is managed by the Python memory manager.  Objects may be
allocated by direct calls to malloc() and then passed to the Python
memory manager to be freed.  The Python memory manager handles that
scenario properly.

While replacing the Python manager is possible, be prepared for some
surprises.  It all depends on the actual modules used in your Python
application and how those modules allocate objects.

/Jean Brouwers
 ProphICy Semiconductor, Inc.



In article <aOydnfnY_fMPawbcRVn-3A at speakeasy.net>, Carl Bevil
<carl_bevilNOSPAM at yahoo.com> wrote:

> Hello all.  If I want to use a custom memory manager to, say, track memory 
> allocations in Python, what's the best way to do this?  I seem to remember 
> there being a way in version 1.5 (or so -- been a while since I used it).  I 
> didn't see anything in the documentation, but I may have missed it.
> 
> I've got the Python source code (v2.3.3) embedded in my application (which is 
> in C++), and would like to somehow override Python's default memory 
> allocators.  Is there an easy or "accepted" way to do this?
> 
> Thanks!
> 
> Carl
> 
> --
> Remove "NOSPAM" to reply in e-mail
>



More information about the Python-list mailing list