in reply to Need Help Identifying Possible Tk Memory Reuse Problem

I think that the dialogbox is not removed from your system. Try either to explicitely destroy() the dialog box, or reuse the dialog box. The latter solution is also done with the standard dialog boxes like the file selection dialog.
  • Comment on Re: Need Help Identifying Possible Tk Memory Leak

Replies are listed 'Best First'.
Re^2: Need Help Identifying Possible Tk Memory Leak
by Grygonos (Chaplain) on Jul 12, 2004 at 16:39 UTC

    Explicitly calling destroy does help. I did that shortly after posting and it made a dramatic difference in the memory allocated each time the window was redrawn.

      Apropos of creating and deleting Tk windows, I wonder about the main program that calls your "guiStart" sub. Does this sub get called numerous times during the execution of the main script? Or is it rather the case that the main script does some stuff, calls this sub, does a few other things after the gui shuts down, then exits?

      If this gui comes up numerous times (for that matter, if the dialog box comes up numerous times), you might consider restructuring the app so that the windows/widgets are all created just once, then made to appear, disappear and reappear as needed, without destroying and recreating them.

      Creating and destroying widgets involves a lot of extra work; it might not be a problem now, but if you have a larger app with more widgets or more data being displayed in widgets, it can slow things down noticeably. Meanwhile, reconfiguring widgets to be visible or not visible, or changing the data that they display, is relatively fast.

        That sounds like a good idea. I would need to figure out how to create them and then pass them around. Thanks for the advice.