Re: Basic GObject question
- From: Andreas Stricker <andreas stricker fela ch>
- To: gtk-app-devel-list gnome org
- Subject: Re: Basic GObject question
- Date: Thu, 28 Dec 2006 11:37:24 +0100
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/
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]