Skip Menu |

This queue is for tickets about the Tk CPAN distribution.

Report information
The Basics
Id: 6556
Status: resolved
Priority: 0/
Queue: Tk

People
Owner: Nobody in particular
Requestors: alvaro [...] rentec.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Binding using anonymous functions leaks memory
#!/usr/local/bin/perl use Tk; my $mw = MainWindow->new; my $button; $button = $mw->Button(-text=>'Click', -command=> sub{ for my $i (1..102400){ $button->bind("<Button-2>", sub{}); } })->pack(); MainLoop; The process grows by about 1.6MBytes every time you press the button, which suggests that 16 bytes of memory are being leaked for every call to bind. The problem also exists in other types of bindings (like using tagBind on a ROText widget). Tk version is 800.023 Perl's version is v5.6.1. OS is `SunOS 5.8 (sparc)'. It also happens on `Linux 2.4.24 (i686)'.
Subject: Re: [cpan #6556] Binding using anonymous functions leaks memory
To: bug-Tk [...] rt.cpan.org
Date: Wed, 09 Jun 2004 09:09:13 +0100
From: Nick Ing-Simmons <nick [...] ing-simmons.net>
RT-Send-Cc:
Guest via RT <bug-Tk@rt.cpan.org> writes: Show quoted text
>This message about Tk was sent to you by guest <> via rt.cpan.org > >Full context and any attached attachments can be found at: ><URL: https://rt.cpan.org/Ticket/Display.html?id=6556 >
Bother, I thought I had nailed that one. This is Tk804.027? Show quoted text
> >#!/usr/local/bin/perl > >use Tk; > >my $mw = MainWindow->new; >my $button; >$button = $mw->Button(-text=>'Click', -command=> sub{ > for my $i (1..102400){ > $button->bind("<Button-2>", sub{}); > } >})->pack(); > >MainLoop; > > > > > > >The process grows by about 1.6MBytes every time you press the button, which suggests that 16 bytes of memory are being leaked for every call to bind. The problem also exists in other types of bindings (like using tagBind on a ROText widget). > >Tk version is 800.023 >Perl's version is v5.6.1. >OS is `SunOS 5.8 (sparc)'. >It also happens on `Linux 2.4.24 (i686)'.
From: srezic [...] cpan.org
[nick@ing-simmons.net - Wed Jun 9 04:08:41 2004]: Show quoted text
> Guest via RT <bug-Tk@rt.cpan.org> writes:
> >This message about Tk was sent to you by guest <> via rt.cpan.org > > > >Full context and any attached attachments can be found at: > ><URL: https://rt.cpan.org/Ticket/Display.html?id=6556 >
> > Bother, I thought I had nailed that one. This is Tk804.027? >
> > > >#!/usr/local/bin/perl > > > >use Tk; > > > >my $mw = MainWindow->new; > >my $button; > >$button = $mw->Button(-text=>'Click', -command=> sub{ > > for my $i (1..102400){ > > $button->bind("<Button-2>", sub{}); > > } > >})->pack(); > > > >MainLoop; > > > > > > > > > > > > > >The process grows by about 1.6MBytes every time you press the button,
> which suggests that 16 bytes of memory are being leaked for every > call to bind. The problem also exists in other types of bindings > (like using tagBind on a ROText widget).
> > > >Tk version is 800.023 > >Perl's version is v5.6.1. > >OS is `SunOS 5.8 (sparc)'. > >It also happens on `Linux 2.4.24 (i686)'.
>
I think this bug can be closed --- I cannot reproduce it with neither Tk800.025 nor Tk804.027 on a Linux Redhat 8.0 machine. Regards, Slaven
I just tried it again with perl5.8.8 + Tk804.027 and using the output of my currmem() function: 7696384,3665920 at /tmp/3tk.pl line 8. 7708672,3678208 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. 7712768,3682304 at /tmp/3tk.pl line 8. ... So it seems that there's no memory leak.