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

lru_cache on instance methods #801

Open
bpdavis86 opened this issue May 8, 2023 · 1 comment
Open

lru_cache on instance methods #801

bpdavis86 opened this issue May 8, 2023 · 1 comment

Comments

@bpdavis86
Copy link

This repo is good work, thanks for providing a valuable resource for tracking researchers!

I noticed you are using lru_cache for instance methods in the repo, e.g. in updater.kalman.KalmanUpdater.predict_measurement. It has been noted that this can cause memory leaks due to cyclic dependency in the garbage collection (the cache never releases reference to the instance).

https://stackoverflow.com/questions/33672412/python-functools-lru-cache-with-instance-methods-release-object

In my own code, I've worked around this by implementing a plain function (or static method) that is lru_cached and then redirecting the instance method to it. Some alternative solutions are provided at the above post. (I see you've used the staticmethod technique in some places as well).

Don't know if you have actually encountered issues with this in practice, but I thought I'd bring it up.

-Ben Davis

@sdhiscocks
Copy link
Member

Thanks for raising this @bpdavis86. It is something we were aware of, but as we don't create many Predictor or Updater objects, shouldn't really be an issue. I think looking at a per instance cache solution is probably best.

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