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

Unmanaged resource leak #16

Open
Brain2000 opened this issue Feb 18, 2019 · 1 comment
Open

Unmanaged resource leak #16

Brain2000 opened this issue Feb 18, 2019 · 1 comment

Comments

@Brain2000
Copy link
Contributor

If you only call Dispose( ) without Close( ) first, the ZSTD_freeCCtx( ) function is not called, eventually leading to an out of memory error after creating and disposing of about 200 compression streams.

Also, if the Close( ) function were to throw an error while flushing the ZSTD stream, the memory would also not be released.

I created a pull request that I believe corrects the issue without changing any behavior.

@Brain2000 Brain2000 changed the title If you only call Dispose( ) without Close( ) first, the ZSTD_freeCCtx( ) function is not called, leading to an out of memory error. Also, if the Close( ) function were to throw an error while flushing the ZSTD stream, the memory would also not be released. By using try/finally on the Close( ), and adding a safety net to Dispose( ) in case Close( ) is not called, the issue seems to be corrected. Note that if you only call Dispose( ), it will not flush the stream, which does not modify the current behavior. A new function to release resources has been added in order to keep from duplicating code in both Close and DIspose. Unmanaged resource leak Feb 18, 2019
@EamonNerbonne
Copy link

For linkability: #15

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