> Can you post a minimal compileable example that manifests this bug? I
> don't have the time to check out and build your whole project, and
> I'm not sure the snippets you posted are showing us enough of the
> context...

This example demonstrates the leak perfectly.

------------------------ leak-example.cxx ------------------------

#include <stdlib.h>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>

#include "debug_new.h"

Fl_Double_Window * win_test_create();
void win_test_destroy();
void cb_test_loop(void*);
void cb_btns_test(Fl_Widget * w, void * v);

Fl_Double_Window * win_test = NULL;
double period = 0.150;

/**************************************************
BUTTON VALUES
**************************************************/
enum
{
  BTN_TEST_EXIT
};


int main()
{
  win_test = win_test_create();
  win_test->show();
  Fl::add_timeout(period, cb_test_loop);
  return(Fl::run());
}

/**************************************************
WINDOW CREATION FUNCTION DECLARATION
**************************************************/
Fl_Double_Window * win_test_create()
{
  Fl_Double_Window * ptr_win = new Fl_Double_Window(800, 600);
  ptr_win->callback(cb_btns_test, (void *) BTN_TEST_EXIT);
  ptr_win->end();
  return ptr_win;
}

void win_test_destroy()
{
  delete win_test;
  win_test = NULL;
}

/**************************************************
CALLBACK FUNCTION DECLARATIONS
**************************************************/
void cb_test_loop(void*)
{
  Fl::repeat_timeout(period, cb_test_loop);
}

void cb_btns_test(Fl_Widget * w, void * v)
{
  switch (int(v))
  {
    case BTN_TEST_EXIT:
      win_test->hide();
      win_test_destroy();
      break;
  }
}

------------------------------------------------------------------

Compiled with: g++ -o leak-example.exe leak-example.cxx debug_new.cpp 
/lib/libfltk.a -lole32 -luuid -lcomctl32 -lwsock32 -mwindows -mno-cygwin

The memory leak detector is at http://wyw.dcweb.cn/leakage.htm.  The page gives 
a lot of good background into how exactly the detector works.

The report given by the detector is: Leaked object at 003F4D98 (size 192, 
00406EF6)

The leak is 192 bytes each time the program is run.  It does not grow as the 
program stays open.

I've been wondering if my calls to add_timeout and repeat_timeout are 
correct... in the documentation there's something about an Fl_Timeout_Handler, 
but it's not used in the examples and I haven't seen anywhere else about how 
that would be used.

>
> However, I'm reasonably sure the fltk timeout code doesn't leak -
> it's been attacked with valgrind etc. on supported platforms, and I
> have code that runs on XP built with mingw that does not appear to be
> exhibiting leakage after days of runtime...
>
> I am not familiar with the tool you used - does it discriminate
> between leaks and memory growth and so forth? I'm thinking it may be
> a false positive of some sort, or possibly some of the functions that
> the timeout calls may be a problem...
>
> --
> Ian
>

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to