Re: Basic GObject question
- From: Stefan Kost <ensonic hora-obscura de>
- To: Andreas Stricker <andreas stricker fela ch>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Basic GObject question
- Date: Sat, 20 Jan 2007 19:54:12 +0200
hi,
Andreas Stricker wrote:
Please don't laugh at me ;P Can someone explain me what reference counting
is for?
Wikipedia explain it not too bad:
http://en.wikipedia.org/wiki/Reference_counting
For glib specific implementation details I recomment to read this document:
http://le-hacker.org/papers/gobject/
or its current for in
http://developer.gnome.org/doc/API/2.0/gobject/index.html
Stefan
And a short overview in my own words:
Each GObject contains a counter that is incremented by each owner of the
object. If one owner don't need the object anymore*, he decrement the
counter. If the counter reach zero, there isn't an owner anymore so the
object can be freed.
So reference counting is something like a half-automated garbage collector.
Reference counting in C still needs discipline and is error prone, but still
easier than manual free() operations.
* usually before the reference (pointer) to the object is overwritten,
replaced or just not used anymore
Cheers, Andy
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]