| David Bremner on Wed, 6 Dec 2000 12:15:01 -0400 (AST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| recursion of the heap |
Well, I thought about my problem with heap usage some more, and came
up with a much shorter example: consider the following (stupid)
function
foo(depth)=
{
if(depth>=1000, return(0));
return(foo(depth+1));
}
I have appended a gp trace at the end of this message, the gist seems
to be that each recursive invocation of the function leaves something on
the heap. Is this a feature? Can it be worked around somehow?
Thanks for any ideas,
David
\\ Trace follows :
Called with: /usr/local/bin/gp -s 10000000 -p 500000 -emacs
GP/PARI CALCULATOR Version 2.0.20 (beta)
ix86 running freebsd 32-bit version
(readline v4.1 enabled, extended help available)
Copyright (C) 1989-1999 by
C. Batut, K. Belabas, D. Bernardi, H. Cohen and M. Olivier.
Type ? for help, \q to quit.
Type ?12 for how to get moral (and possibly technical) support.
realprecision = 28 significant digits
seriesprecision = 16 significant terms
format = g0.28
parisize = 10000000, primelimit = 500000
? \r /tmp/gp_#NOB4XT
? \s
Top : 8a03680 Bottom : 807a000 Current stack : 8a03680
Used : 0 long words (0 K)
Available : 2500000 long words (9764 K)
Occupation of the PARI stack : 0.00 percent
1 objects on heap occupy 15 long words
2 variable names used out of 16383
? foo(0)
%1 = 0
? \s
Top : 8a03680 Bottom : 807a000 Current stack : 8a03680
Used : 0 long words (0 K)
Available : 2500000 long words (9764 K)
Occupation of the PARI stack : 0.00 percent
1003 objects on heap occupy 6027 long words
2 variable names used out of 16383
?