Skip to content
Browse files

[svn r58] Some more thinking about memory management strategies.

--HG--
branch : trunk
  • Loading branch information...
1 parent 6d267fd commit 5eec5b0a2bfed41662a1cc2b6fe6eff5e71d9f40 faassen committed
Showing with 25 additions and 3 deletions.
  1. +25 −3 doc/memorymanagement.txt
View
28 doc/memorymanagement.txt
@@ -42,7 +42,7 @@ i.e. it is not a subtree, this means that tree can be safely garbage
collected.
A special case exists for document references. Each Proxy will always
-have a reference the Document Proxy, as any Node will have such a
+have a reference to the Document Proxy, as any Node will have such a
reference to the Document Node. This means that a Document Node can
only be garbage collected when no more Proxies at all exist anymore
which refer to the Document. This is a separate system from the
@@ -57,5 +57,27 @@ to.
Sometimes this is more difficult: a Proxy may exist pointing to a node
in a subtree that just got connected. The top reference cannot be
-updated. Whether this is a problem I will figure out after I get more
-time to think about it.
+updated. This is a problem in the following case:
+
+ a
+ b c h
+d e f g i j
+ k
+
+now imagine we have a proxy to k, K, and a proxy of i, I. They both
+have a pointer to proxy H.
+
+Now imagine i gets moved under g through proxy I. Proxy I will have an
+updated pointer to proxy A. However, proxy K cannot be updated and still
+points to H, from which it is now in fact disconnected.
+
+proxy H cannot be removed now until proxy A is removed. In addition,
+proxy A has a refcount that is too low because proxy K doesn't point
+to it but should.
+
+Another strategy involves having a reference count on the underlying
+nodes, one per proxy. A node can only be freed if there is no
+descendant-or-self that has the refcount higher than 0. A node, when
+no more Python references to it exist, will check for refcounts first.
+The drawback of this is potentially heavy tree-walking each time a proxy
+can be removed.

0 comments on commit 5eec5b0

Please sign in to comment.
Something went wrong with that request. Please try again.