Recently a TGL user noticed a memory leak when TGL is running.
http://groups.yahoo.com/group/theguiloft/message/593

After an evening of trying to isolate this I've found that it's related to Win32::GUI, and it happens when:
- A Timer
- on a Win32::GUI::Window with the $win->{-dialogui} = 1 or on a Win32::GUI::DialogBox
- fires off an event (an event handler sub doesn't need to exist)

This example program demonstrates the leak. Open the Task Manager and watch the perl.exe process grow a couple of K/sec. Note that the mem usage can vary when the windows get/lose focus, that's not the leak.



#!/usr/local/bin/perl -w
$|++;
use strict;
use Win32::GUI;

my $winTimer = Win32::GUI::Window->new(
    -name => "winTimer",
    -left => 50,
    -top => 50,
    -height => 200,
    -width => 300,
    -text => "Test timer mem leak",
);

$winTimer->{-dialogui} = 0;    #1 => leak, 0 => no leak

my $timTimer = $winTimer->AddTimer("timTimer", 10);    #100 times/sec

$winTimer->Show();
Win32::GUI::Dialog();


sub ::timTimer_Timer {
    print ",";
}

__END__


This seems entirely related to the -dialogui setting, using a Win32::GUI::DialogBox and setting the -dialogui to 0 doesn't result in a leak.


Win32::GUI 1.0
This is perl, v5.8.3 built for MSWin32-x86-multi-thread
(with 8 registered patches, see perl -V for more detail)


/J
-------- ------ ---- --- -- --  --  -     -     -        -          -
Johan Lindström    Sourcerer @ Boss Casinos   johanl AT DarSerMan.com

Latest bookmark: "TCP Connection Passing"
http://tcpcp.sourceforge.net/
dmoz: /Computers/Programming/Languages/JavaScript/ 12


Reply via email to