DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New] Link: http://www.fltk.org/str.php?L2185 Version: 1.3-current Hi. I'm using fltk-1.3-r6700 under linux. Compiler is gcc-4.1.2. First I've noticed very high memory wasting when using menus. On each opening/closing of a menu memory grows extremely. Fluid also perform this problem. But than I've noticed that not menus only reproduces this problem. I've done 2 test applications to reproduse this problem. First one is a window with a button which raises menu on click, second one is a window with a button wich raises another modal window. Here is one related to menus: [code] #include <FL/Fl_Window.H> #include <FL/Fl_Button.H> #include <FL/Fl_Widget.H> #include <FL/Fl_Menu_Item.H> #include <FL/Fl.h> void handle_menu(Fl_Widget*, void*) { puts("menu handle called"); } void cb(Fl_Widget*, void*) { puts("window callback called"); Fl_Menu_Item menu[] = { { "Action1", 0, handle_menu, NULL}, { "Action2", 0, handle_menu, NULL}, { "Action3", 0, handle_menu, NULL}, { 0 } }; const Fl_Menu_Item *m = menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0); if (m) m->do_callback(NULL, NULL); } int main(int argc, char **argv) { Fl_Window window(140, 140); window.begin(); Fl_Button but(20, 20, 100, 100, "push me"); but.callback(cb); window.end(); window.show(); return Fl::run(); } [/code] I've tried to run valgrind tool with this small app. Test scenario - popup menu 10 times. I've got following report: ==402== LEAK SUMMARY: ==402== definitely lost: 456 bytes in 4 blocks. ==402== indirectly lost: 777 bytes in 38 blocks. ==402== possibly lost: 0 bytes in 0 blocks. ==402== still reachable: 7,463,353 bytes in 3,764 blocks. ==402== suppressed: 0 bytes in 0 blocks. ==402== Reachable blocks (those to which a pointer was found) are not shown. "Still reachable" section grows linearly against number of popups. Then I recompiled it with fltk-1.1.9. Report was: ==23139== LEAK SUMMARY: ==23139== definitely lost: 432 bytes in 2 blocks. ==23139== indirectly lost: 728 bytes in 36 blocks. ==23139== possibly lost: 0 bytes in 0 blocks. ==23139== still reachable: 145,705 bytes in 2,590 blocks. ==23139== suppressed: 0 bytes in 0 blocks. Here is second application example: [code] #include <FL/Fl_Window.H> #include <FL/Fl_Button.H> #include <FL/Fl_Widget.H> #include <FL/Fl_Menu_Item.H> #include <FL/Fl.h> static void cb_MyWindow(Fl_Window* o, void*) { Fl::delete_widget(o); } class MyWindow : public Fl_Window { public: MyWindow(int X, int Y, const char *L = 0) : Fl_Window(X, Y, L) { callback((Fl_Callback*)cb_MyWindow); when(FL_WHEN_RELEASE); { new Fl_Button(15, 30, 70, 20, "button"); // some other widgets... } // Fl_Button* o end(); } }; void cb(Fl_Widget*, void*) { MyWindow* ed = new MyWindow(100,100,"name"); ed->set_modal(); ed->show(); } int main(int argc, char **argv) { Fl_Window window(140, 140); window.begin(); Fl_Button but(20, 20, 100, 100, "push me"); but.callback(cb); window.end(); window.show(); Fl::run(); return 0; } [/code] valgrind result are similar as with menu app. With 1.1.9 everything is fine, but 1.3-r6700 wastes memory extremely. Here is link to initial discussion: http://www.fltk.org/newsgroups.php?s18914+gfltk.general+v18909+T0 This bug is VERY critical because for example with just opening and closing menus in fluid during 20 seconds I can gain several dozens of megabytes of wasted memory! Thanks for your effort! /* * gry */ Link: http://www.fltk.org/str.php?L2185 Version: 1.3-current _______________________________________________ fltk-bugs mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-bugs
