Peter Bruin on Fri, 11 Sep 2015 22:38:43 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Trying to allocate too much memory is not handled gracefully


Hi Bill,

> Thanks I have applied your patch (except for the last line, 
> default(parisizemax) should return what the user gave).

Thanks!  The existing behaviour still slightly puzzles me, though:

gp> default(parisizemax,2^63-1)
  ***   Warning: not enough memory, new stack 4611686018427387904
  .........
  ***   Warning: not enough memory, new stack 70368744177664
  ***   Warning: new maximum stack size = 9223372036854775807 (8796093022208.000 Mbytes).
gp> default(parisizemax)
%1 = 70368744177664

The last printed warning shows the user-specified stack size, while
default(parisizemax) returns the actual amount of memory allocated.  I
would find it more logical if instead default(parisizemax) returned the
size that the user asked for (which is what you seem to be saying too),
and if the warning printed the actual allocated size.

> To be honest, I recommend against setting parisizemax to much more
> than 1/2 of the physical memory of the system, because PARI needs some
> memory outside the stack for various operation, and it is easy to make
> a mistake and have the stack fill up quickly. So I would not expect
> anything sensible to occur when setting parisizemax to 2^63.

Sure, I don't think anyone should do this, but it is nicer if at least
GP doesn't crash when the user accidentally tries it...

Peter