Skip Menu |

This queue is for tickets about the Tk CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: lamprecht [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 804.032_501



Subject: Canvas / Textitem memory leak
The following code makes the process grow by ~250 KB on each Button press. Devel::Leak shows constant count of SV. Devel::Leak::NoteSV itself consumes Memory, therefore the call to NoteSV is commented out. Tested with Ubuntu 14.04/ system perl 18.2 as well as perlbrew perl-5.16.3 Tk commit 934d1bdd3c8cefa9a88409c62de97919dc9a522a On a Mac with perl-5.16.3 and cpan Tk 804.032 I can not reproduce this.
Subject: canvasleak.pl
use strict; use warnings; use Tk; #use Devel::Leak; my $dl_handle; my $main = tkinit; my $c = $main->Canvas->pack(-fill => 'both', -expand => 1); $main->Button(-command => \&create_text, -text => 'Create', )->pack; my $items = 50; my @ids; MainLoop(); sub create_text{ for (0..9){ $c->delete('all'); @ids = (); # warn Devel::Leak::NoteSV($dl_handle), "\n"; for my $count (0..$items){ my $id = $c->createText(50,$count* 10, -text => 'o', ); push @ids, $id; $c->addtag('aTag','withtag',$id); } } }
On 2014-11-08 10:02:40, LAMPRECHT wrote: Show quoted text
> The following code makes the process grow by ~250 KB on each Button > press. > Devel::Leak shows constant count of SV. Devel::Leak::NoteSV itself > consumes Memory, therefore the call to NoteSV is commented out. > > Tested with Ubuntu 14.04/ system perl 18.2 as well as perlbrew perl- > 5.16.3 > Tk commit 934d1bdd3c8cefa9a88409c62de97919dc9a522a > > On a Mac with perl-5.16.3 and cpan Tk 804.032 I can not reproduce > this.
I can confirm this on FreeBSD 9.2 with Tk 804.030 and Tk 804.032, both built with XFT=1. Running the script with "valgrind --leak-check=full" shows a lot of problematic places, all related to Tk's InitFont() call and subsequent fontconfig and Xft calls, so probably it has something to do with it. It would be interesting to see if a Tk built with XFT=0 does not have this problem.
Am Sa 08. Nov 2014, 11:05:09, SREZIC schrieb: Show quoted text
> On 2014-11-08 10:02:40, LAMPRECHT wrote:
> > The following code makes the process grow by ~250 KB on each Button > > press. > > Devel::Leak shows constant count of SV. Devel::Leak::NoteSV itself > > consumes Memory, therefore the call to NoteSV is commented out. > > > > Tested with Ubuntu 14.04/ system perl 18.2 as well as perlbrew perl- > > 5.16.3 > > Tk commit 934d1bdd3c8cefa9a88409c62de97919dc9a522a > > > > On a Mac with perl-5.16.3 and cpan Tk 804.032 I can not reproduce > > this.
> > I can confirm this on FreeBSD 9.2 with Tk 804.030 and Tk 804.032, both > built with XFT=1. Running the script with "valgrind --leak-check=full" > shows a lot of problematic places, all related to Tk's InitFont() call > and subsequent fontconfig and Xft calls, so probably it has something > to do with it. It would be interesting to see if a Tk built with XFT=0 > does not have this problem.
Built git checkout commit af7109508f702a63aa4a651709a with XFT=0 perlbrew perl 5.16.3 Ubuntu 14.04. The problem is still present. t/00wmcheck.t ................ 1/1 # # Tk platform: unix # server info: X11R0 The X.Org Foundation 11501000 # window manager: Compiz # version: <unknown> # XFT: no Christoph
RT-Send-CC: SREZIC [...] cpan.org
Am So 09. Nov 2014, 08:09:25, LAMPRECHT schrieb: Show quoted text
> Am Sa 08. Nov 2014, 11:05:09, SREZIC schrieb:
> > On 2014-11-08 10:02:40, LAMPRECHT wrote:
> > > The following code makes the process grow by ~250 KB on each Button > > > press. > > > Devel::Leak shows constant count of SV. Devel::Leak::NoteSV itself > > > consumes Memory, therefore the call to NoteSV is commented out. > > > > > > Tested with Ubuntu 14.04/ system perl 18.2 as well as perlbrew > > > perl- > > > 5.16.3 > > > Tk commit 934d1bdd3c8cefa9a88409c62de97919dc9a522a > > > > > > On a Mac with perl-5.16.3 and cpan Tk 804.032 I can not reproduce > > > this.
> > > > I can confirm this on FreeBSD 9.2 with Tk 804.030 and Tk 804.032, > > both > > built with XFT=1. Running the script with "valgrind --leak- > > check=full" > > shows a lot of problematic places, all related to Tk's InitFont() > > call > > and subsequent fontconfig and Xft calls, so probably it has something > > to do with it. It would be interesting to see if a Tk built with > > XFT=0 > > does not have this problem.
> > Built git checkout commit af7109508f702a63aa4a651709a with XFT=0 > perlbrew perl 5.16.3 > Ubuntu 14.04. > The problem is still present. > > t/00wmcheck.t ................ 1/1 # > # Tk platform: unix > # server info: X11R0 The X.Org Foundation 11501000 > # window manager: Compiz > # version: <unknown> > # XFT: no > > > Christoph
Sorry this was my fault: Building with XFT=0 fixes it.
On 2014-11-10 16:49:04, LAMPRECHT wrote: Show quoted text
> Am So 09. Nov 2014, 08:09:25, LAMPRECHT schrieb:
> > Am Sa 08. Nov 2014, 11:05:09, SREZIC schrieb:
> > > On 2014-11-08 10:02:40, LAMPRECHT wrote:
> > > > The following code makes the process grow by ~250 KB on each Button > > > > press. > > > > Devel::Leak shows constant count of SV. Devel::Leak::NoteSV itself > > > > consumes Memory, therefore the call to NoteSV is commented out. > > > > > > > > Tested with Ubuntu 14.04/ system perl 18.2 as well as perlbrew > > > > perl- > > > > 5.16.3 > > > > Tk commit 934d1bdd3c8cefa9a88409c62de97919dc9a522a > > > > > > > > On a Mac with perl-5.16.3 and cpan Tk 804.032 I can not reproduce > > > > this.
> > > > > > I can confirm this on FreeBSD 9.2 with Tk 804.030 and Tk 804.032, > > > both > > > built with XFT=1. Running the script with "valgrind --leak- > > > check=full" > > > shows a lot of problematic places, all related to Tk's InitFont() > > > call > > > and subsequent fontconfig and Xft calls, so probably it has something > > > to do with it. It would be interesting to see if a Tk built with > > > XFT=0 > > > does not have this problem.
> > > > Built git checkout commit af7109508f702a63aa4a651709a with XFT=0 > > perlbrew perl 5.16.3 > > Ubuntu 14.04. > > The problem is still present. > > > > t/00wmcheck.t ................ 1/1 # > > # Tk platform: unix > > # server info: X11R0 The X.Org Foundation 11501000 > > # window manager: Compiz > > # version: <unknown> > > # XFT: no > > > > > > Christoph
> > Sorry this was my fault: Building with XFT=0 fixes it.
I just pushed an experimental branch XXX-xft-leak-hacking which is adding some missing free and destroy calls. This does not fix all the memory leaks on my system, but valgrind shows significantly less leaks. (Note that it's my convention to mark temporary branches with a XXX prefix --- this branches may be removed or rebased without notice)
Am Mi 12. Nov 2014, 16:33:06, SREZIC schrieb: Show quoted text
> On 2014-11-10 16:49:04, LAMPRECHT wrote:
> > Am So 09. Nov 2014, 08:09:25, LAMPRECHT schrieb:
> > > Am Sa 08. Nov 2014, 11:05:09, SREZIC schrieb:
> > > > On 2014-11-08 10:02:40, LAMPRECHT wrote:
> > > > > The following code makes the process grow by ~250 KB on each > > > > > Button > > > > > press. > > > > > Devel::Leak shows constant count of SV. Devel::Leak::NoteSV > > > > > itself > > > > > consumes Memory, therefore the call to NoteSV is commented out. > > > > > > > > > > Tested with Ubuntu 14.04/ system perl 18.2 as well as perlbrew > > > > > perl- > > > > > 5.16.3 > > > > > Tk commit 934d1bdd3c8cefa9a88409c62de97919dc9a522a > > > > > > > > > > On a Mac with perl-5.16.3 and cpan Tk 804.032 I can not > > > > > reproduce > > > > > this.
> > > > > > > > I can confirm this on FreeBSD 9.2 with Tk 804.030 and Tk 804.032, > > > > both > > > > built with XFT=1. Running the script with "valgrind --leak- > > > > check=full" > > > > shows a lot of problematic places, all related to Tk's InitFont() > > > > call > > > > and subsequent fontconfig and Xft calls, so probably it has > > > > something > > > > to do with it. It would be interesting to see if a Tk built with > > > > XFT=0 > > > > does not have this problem.
> > > > > > Built git checkout commit af7109508f702a63aa4a651709a with XFT=0 > > > perlbrew perl 5.16.3 > > > Ubuntu 14.04. > > > The problem is still present. > > > > > > t/00wmcheck.t ................ 1/1 # > > > # Tk platform: unix > > > # server info: X11R0 The X.Org Foundation 11501000 > > > # window manager: Compiz > > > # version: <unknown> > > > # XFT: no > > > > > > > > > Christoph
> > > > Sorry this was my fault: Building with XFT=0 fixes it.
> > I just pushed an experimental branch XXX-xft-leak-hacking which is > adding some missing free and destroy calls. This does not fix all the > memory leaks on my system, but valgrind shows significantly less > leaks. > > (Note that it's my convention to mark temporary branches with a XXX > prefix --- this branches may be removed or rebased without notice)
I see valgrind reporting 148 Bytes lost (related to InitFont). This is per scipt invocation and does not not depend on how many times the Canvasitems are recreated. Test results are not affected by the patches. I consider this fixed. Thanks a lot! Christoph
On 2014-11-13 05:30:53, LAMPRECHT wrote: Show quoted text
> Am Mi 12. Nov 2014, 16:33:06, SREZIC schrieb:
> > On 2014-11-10 16:49:04, LAMPRECHT wrote:
> > > Am So 09. Nov 2014, 08:09:25, LAMPRECHT schrieb:
> > > > Am Sa 08. Nov 2014, 11:05:09, SREZIC schrieb:
> > > > > On 2014-11-08 10:02:40, LAMPRECHT wrote:
> > > > > > The following code makes the process grow by ~250 KB on each > > > > > > Button > > > > > > press. > > > > > > Devel::Leak shows constant count of SV. Devel::Leak::NoteSV > > > > > > itself > > > > > > consumes Memory, therefore the call to NoteSV is commented > > > > > > out. > > > > > > > > > > > > Tested with Ubuntu 14.04/ system perl 18.2 as well as > > > > > > perlbrew > > > > > > perl- > > > > > > 5.16.3 > > > > > > Tk commit 934d1bdd3c8cefa9a88409c62de97919dc9a522a > > > > > > > > > > > > On a Mac with perl-5.16.3 and cpan Tk 804.032 I can not > > > > > > reproduce > > > > > > this.
> > > > > > > > > > I can confirm this on FreeBSD 9.2 with Tk 804.030 and Tk > > > > > 804.032, > > > > > both > > > > > built with XFT=1. Running the script with "valgrind --leak- > > > > > check=full" > > > > > shows a lot of problematic places, all related to Tk's > > > > > InitFont() > > > > > call > > > > > and subsequent fontconfig and Xft calls, so probably it has > > > > > something > > > > > to do with it. It would be interesting to see if a Tk built > > > > > with > > > > > XFT=0 > > > > > does not have this problem.
> > > > > > > > Built git checkout commit af7109508f702a63aa4a651709a with XFT=0 > > > > perlbrew perl 5.16.3 > > > > Ubuntu 14.04. > > > > The problem is still present. > > > > > > > > t/00wmcheck.t ................ 1/1 # > > > > # Tk platform: unix > > > > # server info: X11R0 The X.Org Foundation 11501000 > > > > # window manager: Compiz > > > > # version: <unknown> > > > > # XFT: no > > > > > > > > > > > > Christoph
> > > > > > Sorry this was my fault: Building with XFT=0 fixes it.
> > > > I just pushed an experimental branch XXX-xft-leak-hacking which is > > adding some missing free and destroy calls. This does not fix all the > > memory leaks on my system, but valgrind shows significantly less > > leaks. > > > > (Note that it's my convention to mark temporary branches with a XXX > > prefix --- this branches may be removed or rebased without notice)
> > I see valgrind reporting 148 Bytes lost (related to InitFont). This is > per scipt invocation and does not not depend on how many times the > Canvasitems are recreated. > Test results are not affected by the patches. I consider this fixed. > > Thanks a lot! Christoph
Now in master as commit 374f75405c6f6896c302638f4b9df13280df5b69
On 2014-11-16 08:37:12, SREZIC wrote: Show quoted text
> On 2014-11-13 05:30:53, LAMPRECHT wrote:
> > Am Mi 12. Nov 2014, 16:33:06, SREZIC schrieb:
> > > On 2014-11-10 16:49:04, LAMPRECHT wrote:
> > > > Am So 09. Nov 2014, 08:09:25, LAMPRECHT schrieb:
> > > > > Am Sa 08. Nov 2014, 11:05:09, SREZIC schrieb:
> > > > > > On 2014-11-08 10:02:40, LAMPRECHT wrote:
> > > > > > > The following code makes the process grow by ~250 KB on each > > > > > > > Button > > > > > > > press. > > > > > > > Devel::Leak shows constant count of SV. Devel::Leak::NoteSV > > > > > > > itself > > > > > > > consumes Memory, therefore the call to NoteSV is commented > > > > > > > out. > > > > > > > > > > > > > > Tested with Ubuntu 14.04/ system perl 18.2 as well as > > > > > > > perlbrew > > > > > > > perl- > > > > > > > 5.16.3 > > > > > > > Tk commit 934d1bdd3c8cefa9a88409c62de97919dc9a522a > > > > > > > > > > > > > > On a Mac with perl-5.16.3 and cpan Tk 804.032 I can not > > > > > > > reproduce > > > > > > > this.
> > > > > > > > > > > > I can confirm this on FreeBSD 9.2 with Tk 804.030 and Tk > > > > > > 804.032, > > > > > > both > > > > > > built with XFT=1. Running the script with "valgrind --leak- > > > > > > check=full" > > > > > > shows a lot of problematic places, all related to Tk's > > > > > > InitFont() > > > > > > call > > > > > > and subsequent fontconfig and Xft calls, so probably it has > > > > > > something > > > > > > to do with it. It would be interesting to see if a Tk built > > > > > > with > > > > > > XFT=0 > > > > > > does not have this problem.
> > > > > > > > > > Built git checkout commit af7109508f702a63aa4a651709a with XFT=0 > > > > > perlbrew perl 5.16.3 > > > > > Ubuntu 14.04. > > > > > The problem is still present. > > > > > > > > > > t/00wmcheck.t ................ 1/1 # > > > > > # Tk platform: unix > > > > > # server info: X11R0 The X.Org Foundation 11501000 > > > > > # window manager: Compiz > > > > > # version: <unknown> > > > > > # XFT: no > > > > > > > > > > > > > > > Christoph
> > > > > > > > Sorry this was my fault: Building with XFT=0 fixes it.
> > > > > > I just pushed an experimental branch XXX-xft-leak-hacking which is > > > adding some missing free and destroy calls. This does not fix all the > > > memory leaks on my system, but valgrind shows significantly less > > > leaks. > > > > > > (Note that it's my convention to mark temporary branches with a XXX > > > prefix --- this branches may be removed or rebased without notice)
> > > > I see valgrind reporting 148 Bytes lost (related to InitFont). This is > > per scipt invocation and does not not depend on how many times the > > Canvasitems are recreated. > > Test results are not affected by the patches. I consider this fixed. > > > > Thanks a lot! Christoph
> > Now in master as commit 374f75405c6f6896c302638f4b9df13280df5b69
And now released as 804.032_501.