FLTK logo

Re: [fltk.general] Memory leakage after creating a new Fl_Tree

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Memory leakage after creating a new Fl_Tree Greg Ercolano Jun 11, 2021  
 
On 6/11/21 6:00 AM, 'pvr...@btinternet.com' via fltk.general wrote:
Is it a simple matter starting at the root item and working my way through the tree and deleting all the branches?

    You should really just call Fl_Tree::clear() to clear the tree.
    To remove a specific item (and its children, if any), Fl_Tree::remove(item).

    You can try to do it yourself by deleting all the branch items, but I'm pretty sure
    you'd end up with the same results as just doing Fl_Tree::clear(). If there was
    something wrong with the deallocating process, I'd think you'd get the same results.

    Fl_Tree_Item's are around 176 bytes per item on a 64 bit machine, similar in size
    to an Fl_Group. On top of that is the memory for the label() string.

    If you parented FLTK widgets to items using Fl_Tree_Item::widget(),
    to clear /those/, you can call: Fl_Tree::Fl_Group::clear(). So to clear the tree
    and all child FLTK widgets I think you'd need to use:

            tree->clear();
            tree->Fl_Group::clear();


--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/6f87c74a-b264-8a9c-c7ae-e084029b7538%40seriss.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.