@matheusbsbs / matheus-bagliano / commits / cb115748ec
Fork 0

Some more memory leak avoidance

This is really the dregs of my effort to not waste memory in git-rev-list, and makes barely one percent of a difference in the memory footprint, but hey, it's also a pretty small patch. It discards the parent lists and the commit buffer after the commit has been shown by git-rev-list (and "git log" - which already did the commit buffer part), and frees the commit list entry that was used by the revision walker. The big win would be to get rid of the "refs" pointer in the object structure (another 5%), because it's only used by fsck. That would require some pretty major surgery to fsck, though, so I'm timid and did the less interesting but much easier part instead. This (percentually) makes a bigger difference to "git log" and friends, since those are walking _just_ commits, and thus the list entries tend to be a bigger percentage of the memory use. But the "list all objects" case does improve too. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Jun 17, 2006 at 18:47 UTC cb115748ec0d4c6faccd09f3637ea436482dd7d5
3 files changed +14 -2
builtin-log.c
+2
@@ -40,6 +40,8 @@ static int cmd_log_wc(int argc, const char **argv, char **envp,
40 log_tree_commit(rev, commit);
41 free(commit->buffer);
42 commit->buffer = NULL;
43 + free_commit_list(commit->parents);
44 + commit->parents = NULL;
45 }
46 return 0;
47 }
builtin-rev-list.c
+8
@@ -89,6 +89,14 @@ static void show_commit(struct commit *commit)
89 printf("%s%c", pretty_header, hdr_termination);
90 }
91 fflush(stdout);
92 + if (commit->parents) {
93 + free_commit_list(commit->parents);
94 + commit->parents = NULL;
95 + }
96 + if (commit->buffer) {
97 + free(commit->buffer);
98 + commit->buffer = NULL;
99 + }
100 }
101
102 static struct object_list **process_blob(struct blob *blob,
revision.c
+4 -2
@@ -949,9 +949,11 @@ struct commit *get_revision(struct rev_info *revs)
949 }
950
951 do {
952 - struct commit *commit = revs->commits->item;
952 + struct commit_list *entry = revs->commits;
953 + struct commit *commit = entry->item;
954
954 - revs->commits = revs->commits->next;
955 + revs->commits = entry->next;
956 + free(entry);
957
958 /*
959 * If we haven't done the list limiting, we need to look at