in reply to Sorted lists in Tk

It's true. MListbox leaks memory, but only because the current Listbox in the most recent releases of Tk leaks. If that were fixed, then it would be fine.

I guess I can take a look at updating MListbox to use TextList instead of Listbox like I intended to a year or two ago. I don't believe it has the same memory leak problem. Perhaps I'll create an option that will use one or the other. Unfortunately, I don't think TextList will be as efficient.

The Leak in Listbox is a fairly new thing. I don't recall it being a problem before Tk804.*

Rob

Replies are listed 'Best First'.
Re^2: Sorted lists in Tk
by mhearse (Chaplain) on May 06, 2005 at 04:13 UTC
    I guess I can take a look at updating MListbox to use TextList instead of Listbox like I intended

    That would be great!

    I'm rather new to Perl Tk. Just out of curiousity, is a widget such as Tk::MListbox 'pure Perl'?

      Yes. MListbox is a widget that is built from several Tk core widgets. MListbox consists of no C code itself, and generally relies on its subwidgets to "do the right thing" when it comes to freeing memory that is no longer required.

      Each sort operation essentially deletes all data from each Listbox (Column), and then loads each Listbox again with the data once it has been sorted. So, as you can imagine leaks in Listbox are obvious very quickly.

      Tk::TextList is a widget that was created several years ago to emulate the functionality provided by Listbox (method calls, look-and-feel, etc), but to give it the power of Text widget tags. In theory, this gives TextList the ability to create and apply styles (tags) at a much greater granularity (per character) than even HList, though, I think the current set of methods support a per-item configuration.

      You should be able to plugin TextList every where there is a Listbox call, and it should work, but now that I think about it, there may have been one or two issues with it that I'm not sure if I ever released fixes for. Feel free to experiment with it. I'm going to look at it again as well.

      If you have the time to devote to it, I definitely encourage you to experiment with HList. I've also used it for similar purposes in the past, with a reasonable amount of success. Whenver I did, however, I always had this nagging feeling that I was using it to solve problems that it wasn't really created to solve.