> mkajdas.mkprod wrote: > > After fixing (a workaround) another leak (see my "Fl_Help_View memory leak" > > post) I am still experiencing an unexplained heap memory usage. > > Basically, anytime I create a window and then delete it, about 1-2 kB of > > memory is never released and is accumulates every time I create the same or > > another window. > > > > My program has many segments like this: > > > > win = new window(...); > > win->show(); > > .. > > win->hide(); > > delete win; > > Actually, you're not supposed to delete FLTK widgets with C++ delete, > FLTK must handle the deletion to ensure the widget(s) are properly > disconnected from the widget tree correctly. > > I believe what you want is Fl::delete_widget() which will schedule > the deletion when you return to the application loop. > http://fltk.org/documentation.php/doc-1.1/Fl.html#Fl.delete_widget > > There should probably be a special section in the docs about > deleting widgets (if there isn't already one), as this seems to > come up a lot on the newsgroup.
The delete_widget() method, as documented, is supposed to handle the important special case of deletion from within a callback. It was thoughtful of the designers to think of this. As for being "not supposed to delete FLTK widgets..," if this were really the case (and, with due respect to Greg, I really doubt it), fltk would simply be broken. So long as the OP's code isn't in a callback, and his win isn't a subwindow, it should be fine, and shouldn't leak any memory. Best, Stan _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

