Reaction + garbage collection

2 views
Skip to first unread message

Sergey Schetinin

unread,
Aug 13, 2009, 11:04:42 PM8/13/09
to better...@googlegroups.com
I wanted to give a warning about problems with cycle collection if
there's a cell -> value link in the cycle. That is, if the cycle has
at least one cell-value relation it will never get collected (for
examle: v = Value(); v.set_value(v); del v)

This is not a bug and cannot be fixed -- cell values are not stored in
an attribute but are stored in a snapshot -- so it is the snapshot
that references the value. The snapshot values don't disappear until
the key disappears. If the cell is garbage collected the key does
"disappear" taking the cell value with it, but if there's a cycle the
snapshot reference of the value prevents it from being gc'ed as well
as anything it references -- and cycle means that, that effectively
prevents the cell from being gc'ed and the key/value as well as the
entire cycle will stay there forever.

This also doesn't get detected by cycle-GC because there's no cycle as
far as GC is concerned -- the cell does not reference its value,
snapshot does, and snapshot will not get GC as it is referenced from
ctrl and any active txns. And it *shouldn't* get GC'ed either -- it
holds values for 'live', not-in-cycle cells too.


I knew this would be the effect of snapshot-based implementation, but
I guess it's not obvious and I have to warn potential users that you
have to be careful not to create this kind of cycle.

Just so you know.


--
Best Regards,
Sergey Schetinin

http://s3bk.com/ -- S3 Backup
http://word-to-html.com/ -- Word to HTML Converter

Reply all
Reply to author
Forward
0 new messages