Branch: Tag:

2008-05-02

2008-05-02 04:15:18 by Martin Stjernholm <mast@lysator.liu.se>

Added Pike.count_memory to be able to see the memory consumed by arbitrary
pike structures.

The Gmp classes have been fixed to accurately report sizes, but there's
probably more to do in other modules.

Rev: lib/modules/Pike.pmod/module.pmod:1.17
Rev: src/array.c:1.205
Rev: src/builtin_functions.c:1.659
Rev: src/gc.c:1.305
Rev: src/gc.h:1.131
Rev: src/mapping.c:1.199
Rev: src/modules/Gmp/acconfig.h:1.8
Rev: src/modules/Gmp/configure.in:1.48
Rev: src/modules/Gmp/mpf.cmod:1.35
Rev: src/modules/Gmp/mpq.cmod:1.27
Rev: src/modules/Gmp/mpz_glue.c:1.178
Rev: src/multiset.c:1.107
Rev: src/object.c:1.288
Rev: src/pike_types.c:1.323
Rev: src/program.c:1.681
Rev: src/stralloc.c:1.216
Rev: src/stralloc.h:1.102

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: mpz_glue.c,v 1.177 2008/05/02 04:03:46 mast Exp $ + || $Id: mpz_glue.c,v 1.178 2008/05/02 04:15:18 mast Exp $   */      #include "global.h"
36:   #include "module_support.h"   #include "bignum.h"   #include "operators.h" + #include "gc.h"      #include "my_gmp.h"   
2147:   #endif    mpz_clear(THIS);   } +  + static void gc_recurse_mpz (struct object *o) + { +  if (Pike_in_gc == GC_PASS_COUNT_MEMORY) +  gc_counted_bytes += + #ifdef MPZ_T_HAS__MP_ALLOC +  THIS[0]._mp_alloc * sizeof (mp_limb_t) + + #else +  mpz_size (THIS) * sizeof (mp_limb_t) +   #endif -  +  sizeof (mpz_t); + } + #endif      PIKE_MODULE_EXIT   {
2305:    ADD_FUNCTION("_random",mpzmod_random,tFunc(tNone,tMpz_ret),0); \    \    set_init_callback(init_mpz_glue); \ -  set_exit_callback(exit_mpz_glue); +  set_exit_callback(exit_mpz_glue); \ +  set_gc_recurse_callback (gc_recurse_mpz);         PIKE_MODULE_INIT