I'm using the following code in Perl/Tk to keep a button hovering over another app at a certain spot in its window. ($ide is a Win32::CtrlGUI object that refers to the other app.)
sub CheckIDE {
my $vis = $ide->get_property('foreground') == $ide ? 1 : 0;
my $coord = $ide->get_property('rect');
exit unless defined $coord;
if ($vis > $curvis) {
$mw->deiconify;
$mw->raise
} elsif ($vis < $curvis) {
$mw->withdraw
}
$curvis = $vis;
my ($rgt, $top) = map {$coord->{$_}} qw/right top/;
$rgt += $dx;
$top += $dy;
$mw->geometry("+$rgt+$top");
$check = $mw->after(10, \&CheckIDE)
}
The code works as I want it to, but I can watch the program's memory allocation climb as it runs. I've isolated the apparent memory leak to the
my $coord = $ide->get_property('rect')
statement. It would appear that the hash referenced by $coord is never returned to the heap when this subroutine returns.
Does this analysis sound right? What can I do prevent the ever-increasing memory footprint?
Thanks,
-Phil
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.