Open Raynos opened 11 years ago
dispose kills all the streams, so there won't be external references to it... there should never be references coming from the objects in history to anything else (or vice versa) so once the streams are disconnected, it should get GCed.
@dominictarr that assumes all references to Row's are GC'd. That's a big assumption.
hmm, okay, so maybe we want to call removeAllListeners()
after next tick on all the rows and sets.
history doesn't contain references to any Row, just the ids of the rows they pertain to.
or! loop all rows null out .state
. null out .sets
and .hist
null out ._events
done!
that is messy! I want a test for this. As I said, you don't need to null hist, because there will be no references to it.
You'll need to find some documentation on triggering GC in javascript, or some sort of test case, I guess using weak-map, if you want to convince me this is a good idea.
@dominictarr I don't want to rely on GC nor my ability to not leak memory with closures when using scuttlebutt on the server. I just want to nuke old docs that are no longer relevant
Well, you are welcome to do that, but I am not bringing code into crdt unless it can be demonstrated to work.
Should crdt listen to the dispose event and purge it's history / memory when it occurs.
How else would I say
doc.destroy()
to indicate the document is no longer necessary and I want to release the memory.