GNU Info

Info Node: (gmp.info)Memory Management

(gmp.info)Memory Management


Next: Reentrancy Prev: Parameter Conventions Up: GMP Basics
Enter node , (file) or (file)node

Memory Management
=================

   The GMP types like `mpz_t' are small, containing only a couple of
sizes, and pointers to allocated data.  Once a variable is initialized,
GMP takes care of all space allocation.  Additional space is allocated
whenever a variable doesn't have enough.

   `mpz_t' and `mpq_t' variables never reduce their allocated space.
Normally this is the best policy, since it avoids frequent reallocation.
Applications that need to return memory to the heap at some particular
point can use `mpz_realloc2', or clear variables no longer needed.

   `mpf_t' variables, in the current implementation, use a fixed amount
of space, determined by the chosen precision and allocated at
initialization, so their size doesn't change.

   All memory is allocated using `malloc' and friends by default, but
this can be changed, see Note: Custom Allocation.  Temporary memory
on the stack is also used (via `alloca'), but this can be changed at
build-time if desired, see Note: Build Options.


automatically generated by info2www version 1.2.2.9