This may work on MacOS X.  An initial, simple test does yield credible
values.

However, I am not a MacOS X expert.  It is unclear which field of the
malloc_statistics_t struct to use and how malloc_zone_statistics with
zone NULL accumulates the stats for all zones.

/Jean Brouwers

#if _MACOSX
#include <malloc/malloc.h>
/* typedef struct malloc_statistics_t {
       unsigned  blocks_in_use;
       size_t    size_in_use;
       size_t    max_size_in_use; -- high water mark of touched memory
       size_t    size_allocated;  -- reserved in memory
   } malloc_statistics_t;
*/
size_t hiwm (
    size_t since)
{
    size_t s;
    malloc_statistics_t t;
    /* get cummulative (?) stats for all zones */
    malloc_zone_statistics(NULL, &t);
    s = t.size_allocated;  /* or t.max_size_in_use? */
    return (s - since);
}
#endif

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to