help with memory usage
daggillies at gmail.com
Tue Mar 10 22:58:42 CET 2009
if you're using C++, why not use a std::list<mpz_class>?
using namespace std;
pfile >> tmp;
On Tue, Mar 10, 2009 at 2:38 PM, Marc Glisse <marc.glisse at normalesup.org> wrote:
> On Tue, 10 Mar 2009, Christ Schlacta wrote:
>>> I believe you should store the mpz_class directly, not a pointer to it (a
>>> mpz_class is not much more than a pointer itself). It will save some
>>> of overhead and simplify the code (no need for new/delete).
>> I tried storing an mpz_class inside the prime_t class, and I
>> experienced string corruption throughout the program. when I switched
>> to using a pointer and a new in the constructor, the problem went
> That only means you didn't do it properly, not that it is a wrong approach.
>>> You could also stop relying on the default memory allocator and either
>>> gmp to use some other allocation function or allocate the buffers
>>> (for read-only never-deallocate numbers like your prime numbers seem to
>>> this should not be hard).
>> I have no clue how I would even do that :(
> If all your numbers fit in say 4 limbs, you could try using mpz_array_init.
> Marc Glisse
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
More information about the gmp-discuss