Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Apr 2004 22:38:31 -0400
From:      Alex Vasylenko <lxv@omut.org>
To:        Tai-hwa Liang <avatar@mmlab.cse.yzu.edu.tw>
Cc:        current@freebsd.org
Subject:   Re: /usr/bin/less weird memory consumption?
Message-ID:  <408098A7.6090407@omut.org>
In-Reply-To: <040416140449E.61901@www.mmlab.cse.yzu.edu.tw>
References:  <040416140449E.61901@www.mmlab.cse.yzu.edu.tw>

next in thread | previous in thread | raw e-mail | index | archive | help
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?408098A7.6090407>