From owner-freebsd-current@FreeBSD.ORG Fri Apr 16 19:38:38 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7F66B16A4CE for ; Fri, 16 Apr 2004 19:38:38 -0700 (PDT) Received: from mail.omut.org (mail.omut.org [216.218.215.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C75E43D55 for ; Fri, 16 Apr 2004 19:38:38 -0700 (PDT) (envelope-from lxv@omut.org) Received: from omut.org (bullfrog.intranet [10.10.10.26]) (authenticated bits=0) by mail.omut.org (8.12.11/8.12.11) with ESMTP id i3H2cWan047387 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 16 Apr 2004 19:38:34 -0700 (PDT) (envelope-from lxv@omut.org) Message-ID: <408098A7.6090407@omut.org> Date: Fri, 16 Apr 2004 22:38:31 -0400 From: Alex Vasylenko User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tai-hwa Liang References: <040416140449E.61901@www.mmlab.cse.yzu.edu.tw> In-Reply-To: <040416140449E.61901@www.mmlab.cse.yzu.edu.tw> Content-Type: multipart/mixed; boundary="------------040401000109090304000208" X-Scanned-By: MIMEDefang 2.42 cc: current@freebsd.org Subject: Re: /usr/bin/less weird memory consumption? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Apr 2004 02:38:38 -0000 This is a multi-part message in MIME format. --------------040401000109090304000208 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Tai-hwa Liang wrote: > Anyone tried to view a file contains *hugh* line with /usr/bin/less in > -CURRENT? > > Sample file: > > dd if=/dev/zero bs=512 count=1500 | tr '\00' ' ' > test.txt > > On my -CURRENT box cvsup'd this morning, "/usr/bin/less text.txt" consumes > about 511 MBytes of memory(see 'top'). -STABLE(less 358) and less 381 on > Debian doesn't seem to have such problem, though. There's a memory leak. The latest less (382) doesn't have this problem. Use attached patch. -- Alex. --------------040401000109090304000208 Content-Type: text/plain; name="less-line.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="less-line.c.diff" Index: line.c =================================================================== RCS file: /home/ncvs/src/contrib/less/line.c,v retrieving revision 1.1.1.3 diff -u -u -r1.1.1.3 line.c --- line.c 7 Jan 2002 20:28:51 -0000 1.1.1.3 +++ line.c 17 Apr 2004 02:21:18 -0000 @@ -92,6 +92,8 @@ } memcpy(new_buf, linebuf, size_linebuf * sizeof(char)); memcpy(new_attr, attr, size_linebuf * sizeof(char)); + free(linebuf); + free(attr); linebuf = new_buf; attr = new_attr; size_linebuf = new_size; --------------040401000109090304000208--