Custom memory manager

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carl Bevil

    #1

    Custom memory manager

    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

  • Jean Brouwers

    #2
    Re: Custom memory manager


    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_fMPaw bcRVn-3A@speakeasy.ne t>, Carl Bevil
    <carl_bevilNOSP AM@yahoo.com> wrote:
    [color=blue]
    > 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
    >[/color]

    Comment

    Working...