Re: Re: Memleak in canvas_paint, update
Al Hooton <[email protected]> Mon, 06 Dec 2004 18:56:42 -0800
| Newsgroups | gmane.comp.scigraphica.gtkextra |
|---|---|
| Message-ID | <[email protected]> |
Adrian,
On Sun, 2004-12-05 at 12:16 -0800, Adrian E. Feiguin wrote:
> Hi Al!
> Thank you so much for your reports. Using Valgrind I was able to fix
> several memory leaks, practically all. There still are a couple silly
> initialization leaks somewhere, probably in gtk or gobject, but I'm
> confident that not in gtkextra. At least the memory usage doesn't grow
> with time, and it's all freed at the end. The leaks where related to
> Pango and gtkplotbubble and gtkplotflux.
> It's all in cvs.
> Hopefuly you'll be able to run your code now!
Man, you did fix up a good bunch of stuff, I can really see the
improvements!
Unfortunately, there is still a lot of memory getting lost in my test
case (and the app I'm working on). With the new updates, I'm seeing
24kB - 28kB+ leaked in every call to gtk_plot_canvas_paint() in the
attached test program. At the average rate of two calls to
canvas_paint() every second, I'll chew up ~90MB/hour. Definitely
better, but obviously not tolerable for an app that will need run for
days/weeks uninterrupted.
I've spent all day today rebuilding gtkextra-2 with full
debugging/profiling, and simplifying my test program to see if the leaks
moved or I could find something else going on. At this point, I have a
simpler test program that still shows these leaks, and the call stack is
the same as my last email, starting with gtk_plot_canvas_paint() and
working down.
Just to be sure this is a real problem, and not only something on my
end, can you build/run the attached testgtkplotcanvas.c, and confirm
that you see it leaking as well? I did a full update from CVS this
morning and built it from scratch to be sure everything was good, so I'm
sure I have a clean starting point.
I'm hoping you can see these leaks too. If not, please let me know, so
we can figure out what's different between your environment and my
environment. I realize these leaks may not be in the gtkextra code
itself, but I'm hoping we can track them down far enough to put a
workaround in place to avoid any problems we may find lower in the
stack.
If anybody else on the list using gtkextra-2 has a few minutes, and
could build/run the attached test program, that would be extremely
helpful too. Just copy the original testgtkplotcanvas.c to another
name, drop the attached file in it's place, rebuild gtkextra-2, then run
gtkextra/testgtkplotcanvas. Open up a terminal and run top - if it's
leaking, you'll see the virtual memory size climbing steadily. I truly
appreciate the help of anyone that can give this a shot and report back
to the list. Maybe it's just something in my environment, in which
case I'll stop bugging everybody... 8^)=
Thanks again for helping me dig through this!
-Al
--------------
#include <math.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
#include <signal.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include "gtkplot.h"
#include "gtkplotdata.h"
#include "gtkplotcanvas.h"
#include "gtkplotcanvasplot.h"
#include "gtkplotcanvasellipse.h"
GtkWidget *canvas;
GtkPlotCanvasChild *child = NULL;
GtkWidget *window1;
void
quit ()
{
gtk_main_quit();
}
void
sigStatus(int signum, siginfo_t *siginfo, void *notused)
{
gtk_plot_canvas_paint(GTK_PLOT_CANVAS(canvas));
}
int main(int argc, char *argv[]){
gint page_width, page_height;
gfloat scale = 1.;
GtkWidget *active_plot;
page_width = GTK_PLOT_LETTER_W * scale;
page_height = GTK_PLOT_LETTER_H * scale;
gtk_init(&argc,&argv);
window1=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(window1,550,650);
gtk_signal_connect (GTK_OBJECT (window1), "destroy",
GTK_SIGNAL_FUNC (quit), NULL);
canvas = gtk_plot_canvas_new(page_width, page_height, 1.);
gtk_widget_show(canvas);
gtk_container_add(GTK_CONTAINER(window1),canvas);
active_plot = gtk_plot_new(NULL);
gtk_widget_show(active_plot);
child = gtk_plot_canvas_plot_new(GTK_PLOT(active_plot));
gtk_plot_canvas_put_child(GTK_PLOT_CANVAS(canvas),
child, .1, .1, .8, .65);
/* Set up the g_timeout */
g_timeout_add((guint) 1000, (GSourceFunc)&sigStatus, (gpointer)NULL);
gtk_widget_show(window1);
gtk_main();
return(0);
}
----------------------
testgtkplotcanvas.c
(text/x-csrc, 1.4 KB)
#include <math.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
#include <signal.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include "gtkplot.h"
#include "gtkplotdata.h"
#include "gtkplotcanvas.h"
#include "gtkplotcanvasplot.h"
#include "gtkplotcanvasellipse.h"
GtkWidget *canvas;
GtkPlotCanvasChild *child = NULL;
GtkWidget *window1;
void
quit ()
{
gtk_main_quit();
}
void
sigStatus(int signum, siginfo_t *siginfo, void *notused)
{
gtk_plot_canvas_paint(GTK_PLOT_CANVAS(canvas));
}
int main(int argc, char *argv[]){
gint page_width, page_height;
gfloat scale = 1.;
GtkWidget *active_plot;
page_width = GTK_PLOT_LETTER_W * scale;
page_height = GTK_PLOT_LETTER_H * scale;
gtk_init(&argc,&argv);
window1=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(window1,550,650);
gtk_signal_connect (GTK_OBJECT (window1), "destroy",
GTK_SIGNAL_FUNC (quit), NULL);
canvas = gtk_plot_canvas_new(page_width, page_height, 1.);
gtk_widget_show(canvas);
gtk_container_add(GTK_CONTAINER(window1),canvas);
active_plot = gtk_plot_new(NULL);
gtk_widget_show(active_plot);
child = gtk_plot_canvas_plot_new(GTK_PLOT(active_plot));
gtk_plot_canvas_put_child(GTK_PLOT_CANVAS(canvas), child, .1, .1, .8, .65);
/* Set up the g_timeout */
g_timeout_add((guint) 1000, (GSourceFunc)&sigStatus, (gpointer)NULL);
gtk_widget_show(window1);
gtk_main();
return(0);
}