[Ekiga-devel-list] Memory management in the engine



Hi,

let me try to document how memory management is handled in the engine.

The basic idea is that each object has an owner, and probably a few
interested objects. For example, an Ekiga::Contact is generally owned by
an Ekiga::Book, but several things could have pointers to it ; for
example views.

The owner is generally the one object which did the "thingie = new
Blah::Blah;", and it's the one which will do the "delete thingie;".

But of course, there is an issue there : how do we know we can delete
thingie if there is an undetermined number of objects interested in it!?

This is what the "removed" message is about : when an object emits this
signal, *all* its watchers should drop it like a hot potato, without
asking any question (don't do thingie.whatever () or thingie->whatever
() -- it may crash!) ; the only thing you can do is use the pointer to
check if you got rid of any reference.

Notice that if you're watching signals from such an object, you won't
need to disconnect anything, since that will be done for you when it's
deleted (that is, if the signalling object inherits sigc::trackable...
I'll have to check we always do!).

This is not very elegant, but it works quite reliably. Feel free to
propose better...

Snark




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