Hello, Monks! 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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.