/usr/bin/less weird memory consumption?
Alex Vasylenko
lxv at omut.org
Fri Apr 16 19:38:38 PDT 2004
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.
-------------- next part --------------
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;
More information about the freebsd-current
mailing list