The Massif tool of Valgrind revealed that parsed tree entries occupy
more than 60% of memory allocated by git-fsck-objects. These entries
can be freed immediately after use, which significantly decreases
memory consumption.
Signed-off-by: Sergey Vlasov <redacted>
---
fsck-objects.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
applies-to: 4b6dbe856a3e63699b299c76f4f1fc5cb34cbe26
0742a20134cc7f58f2c4cbc982a3eb115c6eaf47
diff --git a/fsck-objects.c b/fsck-objects.c
index 17d0536..c1b279e 100644
--- a/fsck-objects.c
+++ b/fsck-objects.c
@@ -184,10 +184,17 @@ static int fsck_tree(struct tree *item)
default:
break;
}
+ free(last->name);
+ free(last);
}
last = entry;
}
+ if (last) {
+ free(last->name);
+ free(last);
+ }
+ item->entries = NULL;
retval = 0;
if (has_full_path) {---
0.99.9.GIT