git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Sergey Vlasov <vsu@altlinux.ru>
Date
Nov 15, 2005, 16:07 UTC
Message-ID
<20051115160715.GF24496@master.mivlgu.local>

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 <vsu@altlinux.ru>
---
 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
Message 1 of 1 in “git-fsck-objects: Free tree entries after use”
  1. git-fsck-objects: Free tree entries after useSergey Vlasov, Nov 15, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.