As far as I can say, there is no memory leak in your program. It is just using a lot of memory if $i and $j become larger than simply 4 or 5 because is is recursing very deeply.
The quick way which might fix this program would be to replace:
by:use strict; print "what is the value of i:";
use strict; use warnings; # it would have warned you about deep recursion use Memoize; memoize ('ackerman'); print "what is the value of i:";
BTW, your function is not the standard Ackermann function as I know it. Using a recursive form of the standard Ackermann function on values 3 and 5 (result = 253), the function is called 42438 times; with memoize, it is called only 636 times. With 3 and 6, the memoized vesion is called 1277 times, the non-memoized version 172233. But even with memoize, don't call it with large numbers.
In reply to Re: memory leak
by Laurent_R
in thread memory leak
by ch.sarath
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |