Best way to know how much memory is used by an mpz_class object

Roberto Bagnara bagnara at cs.unipr.it
Mon Dec 6 16:31:25 CET 2004


In my application I need a way to compute the amount of memory
that is used by an object of type `mpz_class'.
What I do now is something like

   sizeof(x) + x.get_mpz_t()[0]._mp_alloc*SIZEOF_MP_LIMB_T

which, however, relies on the low-level implementation of
`mpz_class'.
Is there a more portable or better way to achieve the same effect?
All the best,

     Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it


More information about the gmp-discuss mailing list