Hey everyone. I'm working on my research project for college and I'm trying to
root out the memory leaks in my program. My program collects data from a sound
card and analyzes it. Unfortunately, I'm getting a 192-byte memory leak, and I
can't figure out where it's coming from.
I'm using fltk-1.1.x-r5891. I didn't see anything in the changelog for the
latest snapshot that looked like it would be the cause of the problem, so I
haven't gotten around to trying it. Also, I'm in Windows using the MinGW
compiler and the debug_new.c (Google "A Cross-Platform Memory Leak Detector" to
find it) as my memory leak checker.
I'm using a repeat_timeout loop to collect the data at regular intervals. If I
comment out the Fl::add_timeout call, the leak goes away. If I uncomment this
call and have the loop completely empty except for the Fl::repeat_timeout call,
I get the leak.
-----------------------------------------------
In sd_win_main.cxx (Main Menu), the button that opens the data collection
window:
void cb_btns_main(Fl_Widget * w, void * v)
{
switch (int(v))
{
case BTN_MAIN_START_COLL:
win_collect = win_coll_create();
win_main->hide();
win_collect->show();
// IF I COMMENT OUT THE NEXT LINE, THE 192 BYTE MEMORY LEAK GOES AWAY
Fl::add_timeout(period, cb_coll_loop); // period = 0.150
break;
// BEHAVIOR FOR OTHER BUTTONS IS DEFINED HERE
}
}
-----------------------------------------------
And then the loop itself in sd_win_coll.cxx (Data Collection window):
void cb_coll_loop(void*)
{
float window_ms; // YES, I KNOW I COULD DO THESE BETTER, BUT I
float bestpeak_freq; // HAVEN'T GOTTEN AROUND TO CHANGING THEM YET
rstream->audioSoFar(window_ms, bestpeak_freq);
main_graph->add_point(bestpeak_freq);
Fl::repeat_timeout(period, cb_coll_loop);
}
For the curious, the rest of my code is on SourceForge. The project name is
SonicData, and I use the SVN repository.
Anyone who can help me with this, I'd really appreciate it. Thanks.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk