Re: Memory problem



Hi Antony
(B
(BWhy bother allocating a new style each time? You can either allocate one new
(Bstyle when you
(Binitialize the app, or just access the default one. The memory leak is
(Bprobably because each time
(Ba new style is created, the old one is not being released. The default one
(Bwill be used by other
(Bwidgets in the tree and won't be released, while GTK may not track new
(Bstyles allocated by the
(Buser for automatic trashing.
(B
(BHope this helps
(B
(BBruce A. Smith
(B(developer, network engineer, troubleshooter, gofer... just about anything
(Byou want me to do)
(B
(B----- Original Message -----
(BFrom: Antony Stace <antony claire co jp>
(BTo: <gnome-devel-list gnome org>; <gtk-app-devel-list gnome org>;
(B<gtk-list gnome org>
(BSent: Wednesday, September 13, 2000 11:18 PM
(BSubject: Memory problem
(B
(B
(B> Hi Folks
(B>
(B> I have a function which is eating up lots of memory.  The function is
(B> listed below and is called every 1 second with the same
(B>
(B> GtkWidget *widget
(B>
(B> being passed to it each time.
(B> What do I need to do to stop it eating up memory.  All I want the
(B> function to do is set the colours of itself and its parent(if it has
(B> one).
(B> Any help greatly appreciated.
(B>
(B> Cheers
(B> Tony
(B>
(B>
(B>
(B>
(B> int SetWidgetColour(GtkWidget *widget, int bordersize, int red,
(B>                      int green, int blue)
(B> {
(B>     GtkStyle *new_style;
(B>     GdkColor color;
(B>
(B>     color.red = red;
(B>     color.green = green;
(B>     color.blue = blue;
(B>
(B>     gdk_color_alloc(gdk_colormap_get_system(), &color);
(B>     new_style = gtk_style_copy(gtk_widget_get_default_style());
(B>     new_style->bg[GTK_STATE_NORMAL] = color;
(B>     new_style->bg[GTK_STATE_PRELIGHT] = color;
(B>     new_style->bg[GTK_STATE_ACTIVE] = color;
(B>     gtk_style_detach (widget->style);
(B>     gtk_widget_set_style(GTK_WIDGET(widget), new_style);
(B>
(B>     return TRUE;
(B> }
(B>
(B> _______________________________________________
(B> gtk-list mailing list
(B> gtk-list gnome org
(B> http://mail.gnome.org/mailman/listinfo/gtk-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]