diff: Fix for memory leak in git_patch #348
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request will fix a memory leak,
that occurs while iterating through patches.
It's quite major issue, my machine run out of memory in couple of minutes.
Please take a look at this fragment of valgrind log.
==6056== 154,660,050 (15,076,512 direct, 139,583,538 indirect) bytes in 52,349 blocks are definitely lost in loss record 788 of 788
==6056== at 0x4C2B590: calloc (vg_replace_malloc.c:618)
==6056== by 0x71159C6: git__calloc (util.h:36)
==6056== by 0x7115D97: diff_patch_alloc_from_diff (diff_patch.c:104)
==6056== by 0x711726A: git_patch_from_diff (diff_patch.c:622)
==6056== by 0x6ED71AF: diff_get_patch_byindex (diff.c:140)
==6056== by 0x55F1DA: PyEval_EvalFrameEx (in /usr/bin/python2.7)
==6056== by 0x55F7B9: PyEval_EvalFrameEx (in /usr/bin/python2.7)
==6056== by 0x55F7B9: PyEval_EvalFrameEx (in /usr/bin/python2.7)
==6056== by 0x55F7B9: PyEval_EvalFrameEx (in /usr/bin/python2.7)
==6056== by 0x55F7B9: PyEval_EvalFrameEx (in /usr/bin/python2.7)
==6056== by 0x55F7B9: PyEval_EvalFrameEx (in /usr/bin/python2.7)
==6056== by 0x55F7B9: PyEval_EvalFrameEx (in /usr/bin/python2.7)