Re: /usr/bin/less weird memory consumption?

From: Alex Vasylenko <lxv_at_omut.org>
Date: Fri, 16 Apr 2004 22:38:31 -0400
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.


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
_at__at_ -92,6 +92,8 _at__at_
 	}
 	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;
Received on Fri Apr 16 2004 - 17:38:38 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:51 UTC