From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yasushi SHOJI Subject: Re: [patch] possible memory leak in diff.c::diff_free_filepair() Date: Sun, 21 Aug 2005 16:14:16 +0900 Message-ID: <87irxzhid3.wl@mail2.atmark-techno.com> References: <87y876gl1r.wl@mail2.atmark-techno.com> <7viry9my6k.fsf@assigned-by-dhcp.cox.net> <877jepo87m.wl@mail2.atmark-techno.com> <7viry9le0g.fsf@assigned-by-dhcp.cox.net> <8764u6ponn.wl@mail2.atmark-techno.com> <7v3bpapkmr.fsf@assigned-by-dhcp.cox.net> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sun Aug 21 09:16:04 2005 Return-path: Received: from vger.kernel.org ([209.132.176.167]) by ciao.gmane.org with esmtp (Exim 4.43) id 1E6k2j-00072r-UC for gcvg-git@gmane.org; Sun, 21 Aug 2005 09:14:58 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750824AbVHUHO1 (ORCPT ); Sun, 21 Aug 2005 03:14:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750822AbVHUHO0 (ORCPT ); Sun, 21 Aug 2005 03:14:26 -0400 Received: from shop.atmark-techno.com ([210.191.215.173]:18395 "EHLO mail2.atmark-techno.com") by vger.kernel.org with ESMTP id S1750816AbVHUHO0 (ORCPT ); Sun, 21 Aug 2005 03:14:26 -0400 Received: from smtp.local-network (dns1.atmark-techno.com [210.191.215.170]) by mail2.atmark-techno.com (Postfix) with ESMTP id A10CA2E58; Sun, 21 Aug 2005 16:14:17 +0900 (JST) Received: from wat.atmark-techno.com (unknown [192.168.10.81]) by smtp.local-network (Postfix) with ESMTP id 47619B61F; Sun, 21 Aug 2005 16:17:18 +0900 (JST) To: Junio C Hamano In-Reply-To: <7v3bpapkmr.fsf@assigned-by-dhcp.cox.net> User-Agent: Wanderlust/2.14.0 Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org At Mon, 15 Aug 2005 21:32:12 -0700, Junio C Hamano wrote: > > Yasushi SHOJI writes: > > > parepare_temp_file() and diff_populate_filespec() has a lot in > > similarity. so it'd be nice to refactor some. and re-introduce > > diff_free_filespec_data() and call right after prep_temp_blob() in > > prepare_temp_file(). > > Another thing that may (or may not) help would be to move that > prepare_temp_file() and stuff to happen in the forked child > process instead of the parent, so that we do not have to worry > about freeing the buffer; it has been some time since I worked > on that part of the code so this may not be an option to make > things easier. well, I couldn't figure out how to do it in child. because the parent need to know temp files in order to delete after child used it. anyway, here is a patch to fix the problem in the simplest way. regards, -- yashi ----------- Make diff_flush a bit more system friendly. This seems to be the simplest way to fix the peak time high memory usage in diff_flush. Don't wait all iteration to free each filepair. Signed-off-by: Yasushi SHOJI --- diff.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) e0f7f97ddc29a9172c2f6c1221eca936aa80835c diff --git a/diff.c b/diff.c --- a/diff.c +++ b/diff.c @@ -1010,9 +1010,8 @@ void diff_flush(int diff_output_style, i diff_flush_name(p, line_termination); break; } - } - for (i = 0; i < q->nr; i++) diff_free_filepair(q->queue[i]); + } free(q->queue); q->queue = NULL; q->nr = q->alloc = 0;