Re: [REGRESSION, BISECTED] `git checkout <branch>` started to be memory hog
- From
Jeff King <peff@peff.net>
- Date
- Jul 22, 2011, 20:36 UTC
- Message-ID
- <20110722203614.GA13232@sigill.intra.peff.net>
- In-Reply-To
- <7vaac6ysd2.fsf@alter.siamese.dyndns.org>
On Fri, Jul 22, 2011 at 01:26:17PM -0700, Junio C Hamano wrote:
Show 6 quoted lines
> Jeff King <peff@peff.net> writes: > > > Did you want me to write a commit message? I think you might do a better > > job of writing a coherent one for this particular patch. > > I didn't do a very good job.
How about:
-- >8 -- Subject: [PATCH] streaming: free git_istream upon closing
Kirill Smelkov noticed that post-1.7.6 "git checkout" started leaking tons of memory. The streaming_write_entry function properly calls close_istream(), but that function did not actually free() the allocated git_istream struct.
The git_istream struct is totally opaque to calling code, and must be heap-allocated by open_istream. Therefore it's not appropriate for callers to have to free it.
This patch makes close_istream() into "close and de-allocate all associated resources". We could add a new "free_istream" call, but there's not much point in letting callers inspect the istream after close. And this patch's semantics make us match fopen/fclose, which is well-known and understood.
Signed-off-by: Jeff King <peff@peff.net> --- streaming.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/streaming.c b/streaming.c index 565f000..f3acc5d 100644 --- a/streaming.c +++ b/streaming.c @@ -93,7 +93,9 @@ struct git_istream { int close_istream(struct git_istream *st) { - return st->vtbl->close(st); + int r = st->vtbl->close(st); + free(st); + return r; } ssize_t read_istream(struct git_istream *st, char *buf, size_t sz)
-- 1.7.6.rc1.12.g65e2