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

Memory leak or creeping memory usage over time #14

Open
danieldaquino opened this issue Jan 10, 2025 · 2 comments
Open

Memory leak or creeping memory usage over time #14

danieldaquino opened this issue Jan 10, 2025 · 2 comments

Comments

@danieldaquino
Copy link
Contributor

notepush: c67a0b5e06b8c0cef351be8efeb0f0fbdd0e0c55

Notepush was observed in production to use higher and higher amounts of memory after a long uptime. We are probably not managing memory well enough and it is using increasing amounts of memory over time.

@jb55
Copy link
Contributor

jb55 commented Jan 12, 2025 via email

@danieldaquino
Copy link
Contributor Author

Daniel D’Aquino @.***> writes:
notepush: c67a0b5e06b8c0cef351be8efeb0f0fbdd0e0c55

Notepush was observed in production to use higher and higher amounts of memory after a long uptime. We are probably not managing memory well enough and it is using increasing amounts of memory over time.
I wonder if this is the note cache? Maybe nostrdb can help here.

Yes, it seems to be the caching logic. I took a quick look at it, and I believe the culprit is our "lazy expiration" logic

Expired cache items stay in memory because no one reads them (so they never lazily clear), and once a user tries to read them, the expired cache item gets replaced with a new one. In other words, the amount of cache items can only stay stable or grow over time. Extrapolating this to infinity, memory exhaustion is basically guaranteed to happen at some point.

I think the fix might be to simply run a cache clearing function periodically instead of lazily.

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