Re: (Easy?) Newbie enquiry re: pointers

Yea, I wasn't sure whether to put a :-( or a :-)   ( :-) ). The thing
is, strings getting copied around so often seems like memory waste to
me... when it passes the text to Pango, does that keep a pointer
itself? freetype? how many times is the same text kept multiple times
in memory? i guess for strings it doesnt really matter because it's
not that much memory wasted. Still, gnome/gtk's memory usage seems
pretty high (see ReducingMemoryUsage on the wiki)


On 10/10/06, David Nečas (Yeti) <yeti physics muni cz> wrote:
On Tue, Oct 10, 2006 at 01:58:20PM -0400, Samuel Cormier-Iijima wrote:
> Whenever you set the text, the widgets will keep copies of the text
> for themselves. (they duplicated the string so it's not showing the
> actual contents of *your* string). To update it, you'll have to set
> the text again for the widgets. :-(

Correct, although the :-( is rather misplaced, because this
is a *good* thing.

Consider the widget just takes your string.  It still
doesn't know you are modifying the contents so you still
have to use some sort of explicit notification.  Not
speaking about changes in length that require memory
reallocation.  Not speaking about locking when some widget's
function could be executed while you are modifying the

In other words, plain C strings typically have only one
owner (at any time point) who can modify it and who is
responsible for freeing the string because other approaches
are hard to get right.  The ownwer is either you or the
widget, not both.


gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

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