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 leak #151

Merged
merged 8 commits into from
May 17, 2019
Merged

Fix memory leak #151

merged 8 commits into from
May 17, 2019

Conversation

ihnorton
Copy link
Member

PyArray_NewFromDescr ignores the NPY_ARRAY_OWNDATA flag, so we
need to set it manually so that NumPy frees the memory.

Fixes #150

Fixes #150

PyArray_NewFromDescr ignores the NPY_ARRAY_OWNDATA flag, so we
need to set it manually so that NumPy frees the memory.

Because we now don't (can't) set the flag in this call, simplify
construction by using PyArray_SimpleNewFromData.

Now that memory is being freed correctly, we must use the NumPy
allocator (PyDataMem_NEW/FREE) so that de-allocation is matched.
- we can't return the result of KV.create, because then the
  array will be left in read mode.
- writes and reads must happen in separate Ctx to avoid hang
Must close and free before raising the error here.
Older NumPy versions don't respect NPY_ENSURECOPY in some
circumstances, which means that the data in the varlen result
array is no longer valid after the underlying buffer is freed.
@ihnorton
Copy link
Member Author

ihnorton commented May 17, 2019

All issues should be resolved on linux/travis. I added a new test as a basic sanity check, based on #150: read 40MB 100x, and check that RSS increase stays under 10%.

@ihnorton
Copy link
Member Author

Targeting 1.5.1 to get a CI run against that release.

@ihnorton ihnorton force-pushed the ihn/fix_leak branch 4 times, most recently from e16ef0f to d1e6b3e Compare May 17, 2019 17:21
- Add psutil install on azure
- Fix file deletion on windows
Copy link
Contributor

@jakebolewski jakebolewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ihnorton ihnorton merged commit 66d6334 into dev May 17, 2019
@gsakkis gsakkis deleted the ihn/fix_leak branch April 6, 2021 13:39
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.

Reading dense array doesn't free memory
2 participants