help with memory usage

Christ Schlacta aarcane at gmail.com
Mon Mar 9 18:42:45 CET 2009


I've got the following simple struct:
class prime_t { //prime list element type.
 public:
   prime_t();
   mpz_class *value;
   prime_t *next;
};

prime_t::prime_t(){
 this->value = new mpz_class;
 this->next = NULL;
}

it ends up being a linked list of mpz_class elements, each of which
ends up being a prime number.
The problem:  I can get several hundred megabytes worth of prime
numbers..  250MB at my last count.  But in memory, 250MB of prime
numbers (stored as newline-delimited strings) ends up being more than
1600MB in memory using this structure.  there are a few other structs,
but the memory usage spikes only on loading the data file, and never
goes down.  I've already used valgrind to check for leaks, there are
none.


--
 (\_/)  This is Bunny. Copy and paste Bunny
(='.'=) into your signature to help him gain
(")_(") world domination.


More information about the gmp-discuss mailing list