On Mon, Sep 14, 2009 at 11:27:43AM +0100, Tim Bunce wrote: > > The next level up in terms of detail is to ask perl's own allocator how > much memory it has allocated. If perl's own allocator is being used then > that information is available via the get_mstats() function.
An alternative and complementary approach: add a function that calls get_mstats() and returns a simple total of allocated memory. That would be fast enough to invoke on every perl subroutine call. In the NYTProf subroutine profiler code, call that sub and record the value, in the same way that it handles the time. In other words, call it before and after the sub call and record the difference, and also accumulate the differece into a global to be factored into the calculation for sub calls higher up the call stack. That would give us, for each subroutine calling location, the memory growth/shrinkage caused by the sub, and caused by the subs that the sub called. Like inclusive and exclusive time, we'd have inclusive and exclusive memory allocation. Cool! Tim. p.s. A separate and complementary feature would be an option to stream sub call info out to the data file as sub calls happen. That would let users track allocation and freeing over time, rather than just seeing totals at the end. --~--~---------~--~----~------------~-------~--~----~ You've received this message because you are subscribed to the Devel::NYTProf Development User group. Group hosted at: http://groups.google.com/group/develnytprof-dev Project hosted at: http://perl-devel-nytprof.googlecode.com CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf To post, email: [email protected] To unsubscribe, email: [email protected] -~----------~----~----~----~------~----~------~--~---
