Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible Memory Leak from Subview Retention #10

Open
wemeetagain opened this issue Mar 25, 2021 · 1 comment
Open

Possible Memory Leak from Subview Retention #10

wemeetagain opened this issue Mar 25, 2021 · 1 comment

Comments

@wemeetagain
Copy link
Contributor

A sub-View contains a reference to the parent View, used to propagate updates to the parent. If the subview is kept around, this reference prevents the parent from being garbage-collected.
You may look at making the reference to the parent a "weak reference", if python allows that sort of thing.

Haven't looked too deep to see if this is an actual issue here, I just know our implementation is based on remerkleable, so seems pertinent.

See ChainSafe/persistent-merkle-tree#26 for our proposed fix.

@protolambda
Copy link
Owner

Thanks for the report. Generally subviews are meant to mutate the subtree in the super view. The GC is indeed problematic views are cached or retained somewhere. The way around it is to not retain sub-views unnecessarily: views are more like temporary typed interfaces, and the bare tree of nodes is wrapped with a view whenever necessary, and the view is then thrown away again when you are done with it. I'd only really retain the view around the beacon state as a whole, and throw away any smaller views (or alternatively "copy" them to un-hook from parent).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants