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 Python reference leak to results struct #229

Merged
merged 4 commits into from
Aug 17, 2020
Merged

Conversation

lgarrison
Copy link
Collaborator

From #227, I think we have a Python reference leak to the results structure. Specifically, I think the following pattern results in a leak:

PyObject *ret = PyList_New(0);//create an empty list
...
return Py_BuildValue("(Od)", ret, c_api_time);

PyBuildValue adds a ref, but the PyList_New reference is never decremented. This PR decrements the ref count after building the tuple, before the return.

Once we verify the fix, I'll port it to the other modules.

@lgarrison
Copy link
Collaborator Author

This is confirmed: sys.getrefcount(extn_results) in DDrppi.py returns 3 instead of 2 without the fix.

@manodeep manodeep linked an issue Aug 15, 2020 that may be closed by this pull request
@lgarrison lgarrison added this to the v2.3.5 milestone Aug 17, 2020
@lgarrison lgarrison merged commit 7dd17ce into master Aug 17, 2020
@lgarrison lgarrison deleted the gh227-refleak branch August 17, 2020 22:29
lgarrison added a commit that referenced this pull request Nov 18, 2020
just to save effort of doing two releases back to back!
@lgarrison lgarrison modified the milestones: v2.3.5, v2.4.0 Nov 18, 2020
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.

DDrppi bug memory leak
2 participants