Custom memory manager

C

Carl Bevil

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
 
J

Jean Brouwers

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top