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

Fix memory leaks in watch and callback API-s #83

Merged
merged 1 commit into from
May 28, 2024

Conversation

keijokapp
Copy link

Resolves #82

Apparently, the references created in watchFuture and fdbFutureToCallback have to be deleted explicitly in addition to being unref-ed. Just deleting wouldn't be enough either. After applying this patch, the memory usage seems to eventually flatline and Valgrind is reasonably happy.

From Node-API doc:

References must be deleted once they are no longer required by the addon. When a reference is deleted, it will no longer prevent the corresponding object from being collected. Failure to delete a persistent reference results in a 'memory leak' with both the native memory for the persistent reference and the corresponding object on the heap being retained forever.

@josephg
Copy link
Owner

josephg commented May 28, 2024

Good catch! Thanks for figuring this out.

@josephg josephg merged commit e38beb9 into josephg:master May 28, 2024
3 checks passed
@keijokapp keijokapp deleted the 82-fix-callback-memory-leak branch May 28, 2024 20:53
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

Successfully merging this pull request may close these issues.

Watch memory leak
2 participants