Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl::Tk application which handles a number of functions to manipulate text and run background processes. The problem I have is that if I leave the application running on my machine, the following day the display somehow gets corrupted. All the widgets disappear or blend in and Tk's main window somewhat displays remnant icons from the desktop!! It's really odd. Almost like a situation when you run out of memory resources and your application starts dragging other icons because of latency issues. However, if you click on the windows the icons seem to function as they are suppoed to; that's if you are lucky enough to click on the right button :-). This is a Windows box with memory to spare. Is this a memory leak? Anyway around it? I need to share the application with a customer and I am hesitant to do so if they are going to have the same problem. I have added the following:
my $repeat = $mw->repeat( 250, sub{$mw->update()} );
before the mainloop but I am not sure if it's enough! Thanks for your feedback.

Replies are listed 'Best First'.
Re: Perl::tk and Display/Memory Issues
by lamprecht (Friar) on Sep 28, 2009 at 13:34 UTC
    my $repeat = $mw->repeat( 250, sub{$mw->update()} );

    Don't do that... MainLoop takes care of updating the UI for you. Explicit calls to update() can be appropriate from within long running callbacks when you need to update status messages or similar things. In your case that timer is useless and might well be part of your problem.


    Cheers, Christoph
      I appreciate your response. The problem, however, was happening before I added the update sub. Your point about the mainloop handling updates is well taken.