GNU MP error - Cannot allocate memory

manoj soni manoj6891 at
Sun Mar 25 20:51:24 CEST 2012

Thanks you so much. I have earlier faced memory leak and debugged it
successfully and now I can assure it is not memory leak because I am
observing "top" in linux and I see that memory allocated to this program is
not continuously increasing to 100%. I will debug more deeply my program to
check to remove any potential memory leak.
As you suggested, If I've run out of virtual memory, how can I configure
more ?

Manoj Soni

On Sun, Mar 25, 2012 at 2:07 PM, Torbjorn Granlund <tg at> wrote:

> manoj soni <manoj6891 at> writes:
>  Hi all,
>  I am using gmp to calculate a matrix of big numbers (as they are out of
>  range of double) using a dynamic programming algorithm. For small input
>  size, it is running successfully but as I increase input size, it throws
>  following error
>  GNU MP: Cannot allocate memory (size=144)
>  I also tried debugging the program using gdb and following is its output
>  (and also backtrace), please have a look and suggest where can be the
>  error. Does it have to do anything with precision in mpf_init2 (I am using
>  1024 and 2048 and it throws error in both cases)
> The reason GMP cannot allocate 144 bytes of memory is surely because
> you've run out of virtual memory.  Configure more.  Or do you suspect
> that your program leaks memory?  In the latter case, perhaps somebody
> here could help you look at the code (unless it is very large).
> --
> Torbjörn

More information about the gmp-discuss mailing list