On Fedora 6, latest v1.1.8 r6025 fltk build
Simplified program:

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_JPEG_Image.H>
using namespace std;

int main (int argc, char *argv[])
{
Fl_Double_Window win(0,0,Fl::w(), Fl::h()-50, "jpeg example");

win.begin();
Fl_Button b(0,0,300,200);
win.end();

Fl_JPEG_Image thumbnail("/tmp/ws251.ltsp.jpg");
b.image(thumbnail);

win.show();
return Fl::run();
}

When I run with valgrind

valgrind --leak-check=full --show-reachable=yes ./jpegbutton4-memory

I get these messages
...

==13334== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 29 from 1)
==13334== malloc/free: in use at exit: 446,155 bytes in 2,791 blocks.
==13334== malloc/free: 8,557 allocs, 5,766 frees, 1,479,574 bytes allocated.
==13334== For counts of detected errors, rerun with: -v
==13334== searching for pointers to 2,791 not-freed blocks.
==13334== checked 671,720 bytes.

...

==13334==    262,848 bytes in 1 blocks are still reachable in loss
record 116 of 116
==13334==    at 0x4005835: operator new[](unsigned) (vg_replace_malloc.c:195)
==13334==    by 0x805927F: innards(unsigned char const*, int, int,
int, int, int, int, int, void (*)(void*, int, int, int, unsigned
char*), void*) (in /root/feb-fltt/jpegbutton4-memory)
==13334==    by 0x8059587: fl_draw_image(unsigned char const*, int,
int, int, int, int, int) (in /root/feb-fltt/jpegbutton4-memory)
==13334==    by 0x805115A: Fl_RGB_Image::draw(int, int, int, int, int,
int) (in /root/feb-fltt/jpegbutton4-memory)
==13334==    by 0x80586D0: Fl_Image::draw(int, int) (in
/root/feb-fltt/jpegbutton4-memory)
==13334==    by 0x8058134: fl_draw(char const*, int, int, int, int,
Fl_Align, void (*)(char const*, int, int, int), Fl_Image*, int) (in
/root/feb-fltt/jpegbutton4-memory)
==13334==    by 0x805869C: fl_draw(char const*, int, int, int, int,
Fl_Align, Fl_Image*, int) (in /root/feb-fltt/jpegbutton4-memory)
==13334==    by 0x805B49D: fl_normal_label(Fl_Label const*, int, int,
int, int, Fl_Align) (in /root/feb-fltt/jpegbutton4-memory)
==13334==    by 0x805B366: Fl_Label::draw(int, int, int, int,
Fl_Align) const (in /root/feb-fltt/jpegbutton4-memory)
==13334==    by 0x805B442: Fl_Widget::draw_label(int, int, int, int,
Fl_Align) const (in /root/feb-fltt/jpegbutton4-memory)
==13334==    by 0x805B4DD: Fl_Widget::draw_label(int, int, int, int)
const (in /root/feb-fltt/jpegbutton4-memory)
==13334==    by 0x805B58D: Fl_Widget::draw_label() const (in
/root/feb-fltt/jpegbutton4-memory)
==13334==
==13334== LEAK SUMMARY:
==13334==    definitely lost: 1,878 bytes in 20 blocks.
==13334==    indirectly lost: 988 bytes in 49 blocks.
==13334==      possibly lost: 0 bytes in 0 blocks.
==13334==    still reachable: 443,289 bytes in 2,722 blocks.
==13334==         suppressed: 0 bytes in 0 blocks.

Here is my question:
Wondering if I need to worry about it? Or is this a leak in fltk?
There are other "still reachable" losses but this is the largest and
the last reported. (and the only one that has anything to do with my
code and fltk)

the man page for valgrind reads

 --show-reachable=<yes|no> [default: no]
              When disabled, the memory leak detector only shows
blocks for which it cannot find a pointer to at all, or it can only
find a
              pointer to the middle of. These blocks are prime
candidates for memory leaks. When enabled, the leak detector also
reports on
              blocks which it could find a pointer to. Your program
could, at least in principle, have freed such blocks before exit.
              Contrast this to blocks for which no pointer, or only an
interior pointer could be found: they are more likely to indicate
              memory leaks, because you do not actually have a pointer
to the start of the block which you can hand to free, even if you
              wanted to.

 As far as my understanding goes, this means the programmer (me) just
forgot to free the memory. The pointer to the unfreed memory still
exists.

-- 
Robert Arkiletian
Eric Hamber Secondary, Vancouver, Canada
Fl_TeacherTool http://www3.telus.net/public/robark/Fl_TeacherTool/
C++ GUI tutorial http://www3.telus.net/public/robark/

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

Reply via email to