Re: Memory problem



On Thu, 5 Mar 2009, maeda <maeda claire co jp> wrote :

I have a function which is eating up lots of memory. The function is
listed below
<snip>

int SetWidgetColour(GtkWidget *widget, int bordersize, int red,
int green, int blue)
{
GtkStyle *new_style;
<snip>

new_style = gtk_style_copy(gtk_widget_get_default_style());
<snip>
gtk_style_detach (widget->style);
gtk_widget_set_style(GTK_WIDGET(widget), new_style);

return TRUE;
}

The function creates a new style on the heap every time it's called. That style is then allocated to the widget, so it must be persistent. This will cause a lot of memory to be used... unless you can absolutely guarantee that the "gtk_style_detach" call results in the old style being free'd. The documentation only says it "may" result in it being "unrealised".
--
Rob Pearce                       http://www.bdt-home.demon.co.uk

The contents of this | Windows NT crashed.
message are purely   | I am the Blue Screen of Death.
my opinion. Don't    | No one hears your screams.
believe a word.      |


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