summaryrefslogtreecommitdiff
path: root/diffcore.h
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2022-11-02 22:01:40 (GMT)
committerTaylor Blau <me@ttaylorr.com>2022-11-03 00:16:34 (GMT)
commit04ae00062d2ec301828e8df9931817be4b2f8653 (patch)
treec059905d1c9d6378f35b84d79f3ca624db6da883 /diffcore.h
parentc03801e19cb8ab36e9c0d17ff3d5e0c3b0f24193 (diff)
downloadgit-04ae00062d2ec301828e8df9931817be4b2f8653.zip
git-04ae00062d2ec301828e8df9931817be4b2f8653.tar.gz
git-04ae00062d2ec301828e8df9931817be4b2f8653.tar.bz2
line-log: free diff queue when processing non-merge commits
When processing a non-merge commit, the line-level log first asks the tree-diff machinery whether any of the files in the given line ranges were modified between the current commit and its parent, and if some of them were, then it loads the contents of those files from both commits to see whether their line ranges were modified and/or need to be adjusted. Alas, it doesn't free() the diff queue holding the results of that query and the contents of those files once its done. This can add up to a substantial amount of leaked memory, especially when the file in question is big and is frequently modified: a user reported "Out of memory, malloc failed" errors with a 2MB text file that was modified ~2800 times [1] (I estimate the leak would use up almost 11GB memory in that case). Free that diff queue to plug this memory leak. However, instead of simply open-coding the necessary three lines, add them as a helper function to the diff API, because it will be useful elsewhere as well. [1] https://public-inbox.org/git/CAFOPqVXz2XwzX8vGU7wLuqb2ZuwTuOFAzBLRM_QPk+NJa=eC-g@mail.gmail.com/ Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 'diffcore.h')
-rw-r--r--diffcore.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/diffcore.h b/diffcore.h
index badc226..9b588a1 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -162,6 +162,7 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *,
struct diff_filespec *,
struct diff_filespec *);
void diff_q(struct diff_queue_struct *, struct diff_filepair *);
+void diff_free_queue(struct diff_queue_struct *q);
/* dir_rename_relevance: the reason we want rename information for a dir */
enum dir_rename_relevance {