A long time ago Jeremy White wrote:
When the code below is run, it leaks User objects in the task manager. This is with the latest codeline running under XP.

And under Win98 and Win2k, all versions of perl that I have.

Both -dropdown and -dropdownlist options highlight the leak. I've have a quick glance through the code but can't seem to find anything that could cause this - a windows bug perhaps?

I'm on a roll today! I've just committed a change that fixes this. I may fix all sorts of other memory leaks for dynamically created/destroyed child windows.

When you call DestroyWindow on a window, Windows automatically calls DestroyWindow on all it's children. However, the drop-down listview dox is not a child of the combobox window (it's a top-level window, so that it can draw outside the main window's client area).

When DestroyWindow is called on a ComboBox, the ComboBox itself takes responsibility for tidying up the drop-down window, which it does in it's WM_NCDESTROY handler.

However, we tidy-up our PERLUD structure in our WM_DESTROY handler, and we never removed our sub-class proc, restoring the original windows prodedure for the controls. Hence, the WM_NCDESTROY messages were being delivered to our subclass proc, and because PERLUD has been freed we no longer knew where to send the WM_NCDESTROY, and so passed it to DefWindProc. Oops, no longer tidying up the Combo-box drop-down.

I've added a couple of lines to to our perud_free() routine to restore the original window proc (if there was one), so the WM_NCDESTORY messages go to the control's handler. This fixes this problem, and potentially many others where controls may have tidied-up in their WM_NCDESTROY handlers.

Regards,
Rob.


It's only a minor problem, and again only an issue if dynamic controls are repeatedly created/destroyed. Saying that, there is only a 10K limit on objects before things go boom - and win32-gui does seem to create a lot of objects - my app - before it's done anything has 650+, so it might be highlighting some other problem.

Cheers,

jez.


use strict;
use warnings;
$|=1;
use Win32::GUI();

my $main = new Win32::GUI::Window (
        -size => [400,400],
);

for (1..100) {
my $box=$main->AddCombobox(
    -name => 'combo',
    #-dropdownlist => 1,
    -dropdown => 1,
    -left => 100,
    -top  =>4,
    -width => 100,
    -height => 100,
);
print "$box \n";
sleep(1);
}



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Perl-Win32-GUI-Hackers mailing list
Perl-Win32-GUI-Hackers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-hackers
http://perl-win32-gui.sourceforge.net/



Reply via email to