On 27.06.2012, at 20:28, Mikhail Tchernychev wrote: > Hello All, > > I was trying to find out how "leak proof" FLTK is and > used a tool you can find here http://vld.codeplex.com/ > > Unfortunately, even a simplest program like > > int main(int argc, char **argv) { > Fl_Window window(340,180); > } > > produces many leaks. Apparently static variables in files > like fl_utf8.cxx just never got freed, only re-allocated all the time. > Fl_Preferences also does not de-allocate its nodes. > Apparently there is no clean up in the library. > > This is really pity because it looks really nice. > > There is also other tool, valgrind, widely used under Linux.
Sigh. I use Valgrind a lot. I ahve debugged millions of lines with it. It's a fantastic tool, but it also produces a lot of false positives. Not mathematically/logically false, but false in the sense that a lot of stuff is cleaned by the OS, even if the program does not take care of it. In general, FLTK is very good with resources and frees those resources that will no longer be needed. Those resources however, that may be needed agin soon will stay in memory until the application quits. For example, there is no sense in deleting fonts once they were loaded, because loading a font is expensive, and they are use frequently. Similarly, hiding a window will not delete anything, because stuff would need to be rebuilt when the window is shown again. Then again, delting a window will automatically delete all children down the tree. Fl_Preferences clears its nodes only when the root node is deleted. Anything else would be false and potentially disastrous. The root Fl_Preferences class reads the entire file and keeps it in RAM until deleted. further Fl_Preferences are merely references to the nodes. There can easily be multiple references to the same node, which is why the nodes are managed by the root, not by the Fl_Preferences link. - Matthias _______________________________________________ fltk-dev mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-dev
