Re: [gdome]Memory management proposal



Am 10.07.01, 18:39:27, schrieb Paolo Casarini <casarini CS UniBO IT>:
> gdome2 will free the libxml2 tree
> structure automatilly when a document is no longer used.

Nice.

>    To do this I'll add a field (that could be called livenodes) to the
> GdomeDocument structure responsible to count the number of tree nodes
> referenced by the user.
> [...]
>    To keep a clear semantic, the refcnt field of the GdomeDocument
> structure will not change his behaviour but if it becomes 0 the wrapper
> structure will not deallocated.

Slight contradiction here? No, I won't complain. I was never interested 
in the semantics of the refcnt field. When that's your memory management 
solution, I'll happily use it.

> The GdomeDocument structure will be
> deallocated at the same time of the libxml2 tree structure when the
> livenodes field become 0.

>    So, to keep the right value in the livenodes field all the times a new
> wrapper structure is allocated the corresponding _mkref function will
> increase the livenodes field, while all the times the refcnt field of a
> already allocated wrapper structure become 0, the corresponding _unref
> function will decrease the livenodes field.

Be sure to decrease the livenodes field not before the dealloation of the 
tree node is complete.

> [...]
>    The system described has also an incidence to the gdome2 performance,
> but I think this could be a smaller problem.

Agree.

Tobias





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