[fpc-pascal] Is such memory statistics possible?

Max Vlasov max.vlasov at gmail.com
Mon Aug 15 10:51:46 CEST 2011


Hi,
reading the recent discussion about lazarus memory consumption, I thought
about collecting some statistics.

The idea is similar to some disk utilities that collects and sort the sizes
of directories. You know when every folder on the computer is scanned and
all the resulting paths are sorted by the summed size. Such utilities
usually help to find space on the hard drive to free.

With memory for every memory allocation we can call the path the addresses
of procedures in stack. So when a function funci() is called from the
function parentfunc() and getmem is called inside func() then we should add
this size to the corresponding entries both for func() and parentfunc().
Sure for every freemem we should decrease from every entry related to the
previous getmem (that might be a challenge since freemem not necessary
follows the same calling pattern). Anyway, if this system is implemented, in
any moment during the program run, the developer can query N most memory
hungry procedures to the moment. And this will include non only the
procedures that call getmem,new  etc, but also higher level ones giving
better hints for further optimization.

Do tools(units) like this already exist? If not, is developing such unit
technically possible/hard with the currently available debug information?

Thanks,

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110815/8f8666e5/attachment.html>


More information about the fpc-pascal mailing list