[gdome]Memory management proposal
- From: Paolo Casarini <casarini CS UniBO IT>
- To: gdome gnome org
- Subject: [gdome]Memory management proposal
- Date: Tue, 10 Jul 2001 18:39:27 +0200 (CEST)
Hi,
I'll try to explain what we are going to implement in gdome2 with
regard to the problem of the deallocation of the libxml2 tree structure.
Our target is to implement a system that can determine when no nodes
are referenced. With such system gdome2 will free the libxml2 tree
structure automatilly when a document is no longer used.
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. Note that it doesn't count the number of
active references, but it counts the number of tree nodes that have at
least one reference. For example, if there are only 2 active references
that point to the same node, the value of the livenodes field will be 1.
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. 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.
The system described increase the memory usage of 4 bytes for each
document. With regard to the memory allocation we have also to consider
that the GdomeDocument wrapper structure will never be deallocated during
the use of a document, even if there aren't references to it. Nevertheless
there is only one GdomeDocument structure for each document.
The system described has also an incidence to the gdome2 performance,
but I think this could be a smaller problem.
Comments?
Thanx
Paolo
--
Paolo Casarini - casarini cs unibo it
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]