I ran into a memory leak in a system I'm working on
I see no leekage. Memory usage is more or less constant.
#!/usr/bin/perl use strict; use warnings; sub bar { if ( foo() ) { goto &bar; } return; } my $i; sub foo { return $i++ < 500_000; } $i=0; bar(); print("Press Enter to continue"); <STDIN>; # 32,824K $i=0; bar(); print("Press Enter to continue"); <STDIN>; # 32,872K $i=0; bar(); print("Press Enter to continue"); <STDIN>; # 32,860K $i=0; bar(); print("Press Enter to continue"); <STDIN>; # 32,856K
The stack and all lexical variables should be deallocated when goto is called, right?
Should? Dunno. Does? No. ( That's why the memory usage increases for each recursive call to bar. )
In reply to Re: memory leak when using tail recursion?
by ikegami
in thread memory leak when using tail recursion?
by juddhuck
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |