sha1_file: fix delta_stack memory leak in unpack_entry
PATCH 1/1 sha1_file: fix delta_stack memory leak in unpack_entry
This delta_stack array can grow to any length depending on the actual delta chain, but we forget to free it. Normally it does not matter because we use small_delta_stack[] from stack and small_delta_stack can hold 64-delta chains, more than standard --depth=50 in pack-objects.
---
Found when trying to see if making some objects loose at this phase could help git-blame and how many objects will be loosened. Gotta go soon, didn't really test it, but I bet it'll work.
sha1_file.c | 4 ++++ 1 file changed, 4 insertions(+)
sha1_file.c +4 -0
@@ -2289,6 +2289,10 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset, *final_size = size;unuse_pack (&w_curs); + +if (delta_stack != small_delta_stack) +free (delta_stack); +return data; }
Signature · 1 line
1.9.0.40.gaa8c3ea
Quoted 10 lines · Nguyễn Thái Ngọc Duy
This
delta_stackarray can grow to any length depending on the actual delta chain, but we forget to free it. Normally it does not matter because we use small_delta_stack[] from stack andsmall_delta_stackcan hold 64-delta chains, more than standard --depth=50 in pack-objects.Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>---
Found when trying to see if making some objects loose at this phase could help git-blame and how many objects will be loosened. Gotta go soon, didn't really test it, but I bet it'll work.
This looks correct to me.
For fun, I measured "git fsck" on linux.git via massif. The peak memory usage dropped from 368MB to 306MB. That's probably an extreme case because it's a big repo and was packed with "--aggressive", but it's still a nice improvement.
-Peff
Quoted 7 lines · Jeff King
Quoted 5 lines · Nguyễn Thái Ngọc Duy
This
delta_stackarray can grow to any length depending on the actual delta chain, but we forget to free it. Normally it does not matter because we use small_delta_stack[] from stack andsmall_delta_stackcan hold 64-delta chains, more than standard --depth=50 in pack-objects.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>---
Found when trying to see if making some objects loose at this phase could help git-blame and how many objects will be loosened. Gotta go soon, didn't really test it, but I bet it'll work.This looks correct to me.
This comes from abe601bb, right? The change looks correct to me, too.
Quoted 4 lines
For fun, I measured "git fsck" on linux.git via massif. The peak memory usage dropped from 368MB to 306MB. That's probably an extreme case because it's a big repo and was packed with "--aggressive", but it's still a nice improvement.
Thanks.
Quoted 7 lines · Junio C Hamano
Quoted 4 lines
Quoted 4 lines
This
delta_stackarray can grow to any length depending on the actual delta chain, but we forget to free it. Normally it does not matter because we use small_delta_stack[] from stack andsmall_delta_stackcan hold 64-delta chains, more than standard --depth=50 in pack-objects.[...]
This comes from
abe601bb, right? The change looks correct to me, too.
Yes, it does.
-Peff
Quoted 15 lines · Junio C Hamano
Quoted 13 lines · Jeff King
Quoted 10 lines · Nguyễn Thái Ngọc Duy
This
delta_stackarray can grow to any length depending on the actual delta chain, but we forget to free it. Normally it does not matter because we use small_delta_stack[] from stack andsmall_delta_stackcan hold 64-delta chains, more than standard --depth=50 in pack-objects.Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>---
Found when trying to see if making some objects loose at this phase could help git-blame and how many objects will be loosened. Gotta go soon, didn't really test it, but I bet it'll work.
Quoted 3 lines
Quoted 1 line
This looks correct to me.
This comes from
abe601bb, right? The change looks correct to me, too.
Ow, sorry about that. Thanks for the fix!
Signature · 2 lines
Thomas Rast [email protected]