[Python-Dev] Updated PEP 454 (tracemalloc): no more metrics!

MRAB python at mrabarnett.plus.com
Thu Oct 24 17:32:30 CEST 2013


On 24/10/2013 15:40, Kristján Valur Jónsson wrote:
>
>
>> -----Original Message-----
>> From: Nick Coghlan [mailto:ncoghlan at gmail.com]
>> Sent: 24. október 2013 12:44
>> To: Kristján Valur Jónsson
>> Cc: Python Dev
>> Subject: Re: [Python-Dev] Updated PEP 454 (tracemalloc): no more metrics!
>> Not everything is a PC that you can just add more memory to (or switch to a
>> lab server with the same CPU architecture but more RAM).
>>
>> If Victor were only interested in analysing x86[_64] software, I'd agree with
>> you, but embedded scenarios don't always offer that freedom to do
>> resource consumption analysis on a more powerful system.
>>
> Indeed not.
> In fact, I was faced with the same problem when developing for the PS3.
> My solution was to not do it.  The memory profiler running on the PS3
> performs no analysis whatsoever.  For every operation (malloc/realloc/free) it
> simply records the address and the traceback and sends it along its merry way
> to a server which is listening on a TCP or UDP port
>
> If anyone is interested in adding that functionality to tracemalloc, I can contribute
> my code as an example.
> A corresponding server is a pure-python affair.
>
> An added benefit of a client-server approach is that there the memory profiling
> tool is non-intrusive (apart from slowing down the execution either due to
> cpu or network blockage) and so has to take no special steps to exclude itself from the profiling.
>
When I was looking for memory leaks in the regex module I simply wrote 
all of the allocations, reallocations and deallocations to a log file 
and then parsed it afterwards using a Python script. Simple, but effective.




More information about the Python-Dev mailing list