Author vstinner
Recipients Rhamphoryncus, amaury.forgeotdarc, barry, gregory.p.smith, jlaurila, jszakmeister, kristjan.jonsson, ncoghlan, neilo, pitrou, pjmcnerney, rhettinger, tlesher, vstinner
Date 2013-05-31.23:40:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1370043650.76.0.518033600652.issue3329@psf.upfronthosting.co.za>
In-reply-to
Content
> typedef void *(*PyCCP_Malloc_t)(size_t size, void *arg, const char *file, int line, const char *msg);

I don't understand the purpose of the filename and line number. Python does not have such information. Is it just to have the API expected by Unreal engine?

What is the message? How is it filled?

--

I'm proposing a simpler prototype:

void* (*malloc) (size_t);

Just because Python does not use or have less or more. I'm not against adding an arbitrary void* argument, it should not hurt, and may be required by some other applications or libraries.

@kristjan.jonsson: Can you adapt your tool to fit the following API?

PyAPI_FUNC(int) Py_SetAllocators(
    char api,
    void* (*malloc) (size_t size, void *data),
    void* (*realloc) (void* ptr, size_t size, void *data),
    void (*free) (void* ptr, void *data)
    );

--

My pytracemalloc project hooks allocation functions and then use C Python functions to get the current filename and line number. No need to modify the C code to pass __FILE__ and __LINE__.

It can produce such summary:

2013-02-28 23:40:18: Top 5 allocations per file
#1: .../Lib/test/regrtest.py: 3998 KB
#2: .../Lib/unittest/case.py: 2343 KB
#3: .../ctypes/test/__init__.py: 513 KB
#4: .../Lib/encodings/__init__.py: 525 KB
#5: .../Lib/compiler/transformer.py: 438 KB
other: 32119 KB
Total allocated size: 39939 KB

You can also configure it to display also the line number.

https://pypi.python.org/pypi/pytracemalloc
History
Date User Action Args
2013-05-31 23:40:50vstinnersetrecipients: + vstinner, barry, rhettinger, gregory.p.smith, amaury.forgeotdarc, ncoghlan, Rhamphoryncus, pitrou, kristjan.jonsson, jszakmeister, tlesher, jlaurila, neilo, pjmcnerney
2013-05-31 23:40:50vstinnersetmessageid: <1370043650.76.0.518033600652.issue3329@psf.upfronthosting.co.za>
2013-05-31 23:40:50vstinnerlinkissue3329 messages
2013-05-31 23:40:50vstinnercreate