memory problem with GMP 5

Paul Zimmermann Paul.Zimmermann at loria.fr
Sat Jan 23 20:13:53 CET 2010


> With the GNU libc, there is malloc_stats (I haven't used it recently, but 
> I seem to remember that it gives the right information). Other 
> implementations provide similar information, but there is no common way to 
> access it.

thanks. With GMP 5.0.0 I get:

system bytes     =     659456
in use bytes     =       2512
Total (incl. mmap):
system bytes     =  999870464
in use bytes     =  999213520
max mmap regions =          6
max mmap bytes   = 3504922624

with GMP 4.3.2:

system bytes     =     200704
in use bytes     =       2512
Total (incl. mmap):
system bytes     =  999411712
in use bytes     =  999213520
max mmap regions =          6
max mmap bytes   = 2207744000

and with gmp-5.0.0-20100123:

system bytes     =     598016
in use bytes     =       2512
Total (incl. mmap):
system bytes     =  999809024
in use bytes     =  999213520
max mmap regions =          6
max mmap bytes   = 3005407232

Paul

#include <stdio.h>
#include <stdlib.h>
#include "gmp.h"

int
main()
{
  mp_ptr a, b, c;
  mp_size_t sa = 25465231, sb = 36985114;
  printf ("GMP %s\n", gmp_version);
  a = malloc (sa * sizeof (mp_limb_t));
  b = malloc (sb * sizeof (mp_limb_t));
  c = malloc ((sa + sb) * sizeof (mp_limb_t));
  mpn_random (a, sa);
  mpn_random(b, sb);
  printf ("start product\n");
  fflush (stdout);
  mpn_mul (c, a, sa, b, sb);
  printf ("end product\n");
  fflush (stdout);

  malloc_stats ();

  return 0;
}


More information about the gmp-bugs mailing list