Re: gtk_entry_set_text() and very fast updates
- From: "Bruce A. Smith" <bruces mail petech ac za>
- To: "David Ford" <david linux com>
- Cc: <gtk-list gnome org>
- Subject: Re: gtk_entry_set_text() and very fast updates
- Date: Wed, 15 Nov 2000 09:08:54 -0800
Hi
I may be wrong here, but doesn't gtk_entry_set_text make a copy of the
string given. Try to
free temp each time after the text setting. Unfortunately I'm nowhere near a
GTK+ box to give this
a test myself. This may just break the app badly if it needs the original.
Hope this works.
Bruce
----- Original Message -----
From: "David Ford" <david linux com>
To: "Havoc Pennington" <hp redhat com>
Cc: <gtk-list gnome org>
Sent: Tuesday, November 14, 2000 10:47 PM
Subject: Re: gtk_entry_set_text() and very fast updates
> Havoc Pennington wrote:
>
> > David Ford <david linux com> writes:
> > > Question, I have need to update an entry box on the order of ~200ms
> > > intervals. Using gtk_entry_set_text() only seems to grow in memory
> > > usage.
> > >
> > > [...]
> > > commaval=commafy(tuples);
> > > sprintf(temp, "%*s", 9, commaval);
> > > free(commaval);
> > > gtk_entry_set_text(GTK_ENTRY(count_field), temp);
> > > [...]
> > >
> > > Consider this the body of a loop. Yes, I'm new to gtk starting last
> > > wednesday evening. Can someone recommend a leak proof method other
than
> > > widget de/construction?
> > >
> >
> > If you're running that in a loop without ever running the GTK main
> > loop, the memory leak is probably just GTK queuing up more and more
> > redraws or something; try running the main loop once in a while.
>
> The loop is iterated by a gtk timer, the program sits in gtk main
normally.
> sql_refresh is initially called by a button. I've commented everything in
> the function except for the set_text. Assume conn is null only for the
first
> call and valid thereafter. It boils down to the below with main() having
> entered while()..gtk_main().
>
> sql_refresh()
> [...]
> if(!conn) {
> auto_push_statusbar("You are not linked to the SQL server -- Going
> online");
> sql_connect();
> if(!conn) {
> auto_push_statusbar("Unable to link to SQL server");
> return;
> }
> else
> auto_push_statusbar("Connected to SQL server, refreshing
every...");
>
> timeoutid=gtk_timeout_add(200, (void *)&auto_refresh, NULL);
> }
> [...]
> gtk_entry_set_text()
> }
>
> auto_refresh()
> {
> GtkButton *dummy1=NULL;
> gpointer dummy2=0;
> sql_refresh(dummy1, dummy2);
> return;
> }
>
> If I comment out the set_text call, I can run the program at 1ms for 20
> minutes and see no mem leak.
>
> -d
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]