Hello Monks!
I built an application in Perl/Tk, but there seems to be some memory problem. The code is a bit longish, but I managed to locate where the problem comes from. Every time I use update on the MainWindow in order to update the ProgressBar, there is a memory build up. So here is a very short Perl/TK application:
use strict;
use Tk;
use Tk::ProgressBar;
my $mw=MainWindow->new;
my $percent;
my $pb=$mw->ProgressBar(
-height => 0,
-width => 20,
-length => 100,
-colors=>[0,'blue'],
-blocks=>100,
-variable=>\$percent)->pack;
my $btn=$mw->Button(
-command => \&show_progress,
-text => 'Run program',
)->pack;
MainLoop;
sub show_progress{
for (1..100) {
$percent=rand(100);
$mw->update();
}
}
So I was clicking the button on this simple application and was watching the memory usage with the task manager (XP). Every time I click on the button there is memory build up and I just can not figure where this is coming from. It just never goes down.
Click......Memory
1........10,428K
2........10,512K
3........10,576K
4........10,648K
5........10,716K
6........10,780K
7........10,852K
.
etc
I now these are very small increments, but is this some sort of memory leak with the ProgressBar or something else that I am missing here?
This is extremely simple application. When I did a bit more complicated stuff, the memory build up was enormous. A way to overcome this is closing the application every time, but it is a bit annoying. It seems that this is only associated with the ProgressBar widget, not with the update. I tried only update on the ProgressBar widget, but it does not make a difference.
Could you please help me here?
I am using
Perl/Tk 804.027-r6
Perl v5.8.8 MSWin32-x86-multi-thread
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.