radiocosmology/caput — pull request #13 by jrs65 (2014-10-05 22:02:40+00:00)
Title: Remove cyclic references in memh5

The tree structure of memh5 creates cyclic references with the `parent` and `_root` attributes. In some cases which are no quite clear the python garbage collector is unable to free the memory and it's causing out of memory issues. This particularly happens when using `AnData.from_acq_h5` to load `archive` type files, but not the `acq0` type files (I don't understand why).

This patch replaces the parent and root attributes with `weakref`s to break the cycles. This is completely effective, but does have the side effect that if we lose the reference to the parent, but not the child, the parent will be freed, and the `.parent` and `.file` attributes won't work. I can't think of a great way of avoiding this, it's a little undesirable, but the memory leaks are worse.