DORMANTno replies

[PATCH] git-fsck-objects: Free tree entries after use

From: Sergey Vlasov <hidden>
Date: 2016-06-15 22:42:12
Subsystem: the rest · Maintainer: Linus Torvalds

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help