santeri has asked for the wisdom of the Perl Monks concerning the following question:

Hello. I have a problem with Tkx memory leaks. When application calls Tkx::after(delay, callback) it does not frees used memory. Approximately 4kb per call. Any suggestions? Thanks..
#!/usr/bin/perl use strict; use Tkx; # forward declarations sub func_a; sub func_b; # functions (loops) sub func_a { # STUFF.. Tkx::after(100, [\&func_a]); } sub func_b { # STUFF.. Tkx::after(100, [\&func_b]); } # timed start Tkx::after(100, [\&func_a]); Tkx::after(100, [\&func_b]); Tkx::MainLoop(); 1; __END__
It's not recursion, sub will be started after the current has returned.

Replies are listed 'Best First'.
Re: Tkx::after memory leaks
by Anonymous Monk on Mar 07, 2010 at 11:49 UTC
    An infinite recursion loop that leaks memory, say it ain't so George, say it ain't so :)
    #!/usr/bin/perl use strict; use warnings; use Tkx; # forward declarations sub func_a; sub func_b; # functions (loops) sub func_a { # STUFF.. Tkx::after(100, sub { "the stuffa not leaks "; }); } sub func_b { # STUFF.. Tkx::after(100, sub { "the stuffb not leaks "; }); } # timed start Tkx::after(100, [\&func_a]); Tkx::after(100, [\&func_b]); Tkx::MainLoop(); 1; __END__
      Memory flows even without infinite loop, just list of Tkx::after()
        What? The code I gave you doesn't leak memory for me. Your recursive code does leak.