Hi,
What version of Win32::GUI are you using? I don't see any memory leak when
running your code? You don't need to do anything to 'destroy' a control,
Win32::GUI should do the right thing (see below). The same also applies to
windows, you can create/destroy (let them go out of scope) just like normal
objects and all memory should be released. Well, I think anyway:)
Cheers,
jez.
use strict; use Win32::GUI(); my $main = Win32::GUI::Window->new(-name =>
'Main', -text => 'Perl', -width => 200, -height => 200);
$main->AddLabel(-name => "Label", -text => "Hello, world", -left => 20, -top =>
20, -notify => 1);
sub Label_Click { for (1..10000) {
#Win32::GUI::DestroyWindow($main->{"Label"}{-handle}); <--- not need#delete
$main->{"Label"}; <- not need.$main->AddLabel(-name => "Label", -text =>
rand(), -left => 20, -top => 20, -notify => 1); } }
$main->Show(); Win32::GUI::Dialog();
sub Main_Terminate { -1; }
> From: war...@mail.ru
> To: perl-win32-gui-users@lists.sourceforge.net
> Date: Wed, 23 Dec 2009 12:22:03 +0300
> Subject: [perl-win32-gui-users] memory leak problem
>
> Hello, Win32::GUI users!
>
> I have an application which extensively creates and destroys window controls,
> such as labels, buttons etc..
> To get rid from window control I use Win32::GUI::DestroyWindow, but seems
> this method is not working properly, see example:
>
> ==================
> use strict;
> use Win32::GUI();
> my $main = Win32::GUI::Window->new(-name => 'Main', -text => 'Perl', -width
> => 200, -height => 200);
>
> $main->AddLabel(-name => "Label", -text => "Hello, world", -left => 20, -top
> => 20, -notify => 1);
>
> sub Label_Click
> {
> for (1..1000)
> {
> Win32::GUI::DestroyWindow($main->{"Label"}{-handle});
> delete $main->{"Label"};
> $main->AddLabel(-name => "Label", -text => rand(), -left => 20, -top
> => 20, -notify => 1);
> }
> }
>
> $main->Show(); Win32::GUI::Dialog();
>
> sub Main_Terminate { -1; }
> =============
>
> When I click on label the program creates/destroys control many times. But
> seems there is huge memory leak, when using this method. Is there any
> "proper" way do destroy window control?
>
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
_________________________________________________________________
Got more than one Hotmail account? Save time by linking them together
http://clk.atdmt.com/UKM/go/186394591/direct/01/
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/