Re: Memory problem

Hi Antony

Why bother allocating a new style each time? You can either allocate one new
style when you
initialize the app, or just access the default one. The memory leak is
probably because each time
a new style is created, the old one is not being released. The default one
will be used by other
widgets in the tree and won't be released, while GTK may not track new
styles allocated by the
user for automatic trashing.

Hope this helps

Bruce A. Smith
(developer, network engineer, troubleshooter, gofer... just about anything
you want me to do)

----- Original Message -----
From: Antony Stace <antony claire co jp>
To: <gnome-devel-list gnome org>; <gtk-app-devel-list gnome org>;
<gtk-list gnome org>
Sent: Wednesday, September 13, 2000 11:18 PM
Subject: Memory problem

> Hi Folks
> I have a function which is eating up lots of memory.  The function is
> listed below and is called every 1 second with the same
> GtkWidget *widget
> being passed to it each time.
> What do I need to do to stop it eating up memory.  All I want the
> function to do is set the colours of itself and its parent(if it has
> one).
> Any help greatly appreciated.
> Cheers
> Tony
> int SetWidgetColour(GtkWidget *widget, int bordersize, int red,
>                      int green, int blue)
> {
>     GtkStyle *new_style;
>     GdkColor color;
> = red;
> = green;
> = blue;
>     gdk_color_alloc(gdk_colormap_get_system(), &color);
>     new_style = gtk_style_copy(gtk_widget_get_default_style());
>     new_style->bg[GTK_STATE_NORMAL] = color;
>     new_style->bg[GTK_STATE_PRELIGHT] = color;
>     new_style->bg[GTK_STATE_ACTIVE] = color;
>     gtk_style_detach (widget->style);
>     gtk_widget_set_style(GTK_WIDGET(widget), new_style);
>     return TRUE;
> }
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org

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