[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [PATCH] was Re:: memory usage increases with redirection on loop
From: Jon Tollefson <kniht () linux ! vnet ! ibm ! com>
Date: 2012-10-18 21:08:35
Message-ID: 50806FD3.7040806 () linux ! vnet ! ibm ! com
[Download RAW message or body]
On 10/10/2012 04:06 AM, Michael Tokarev wrote:
...
> ==20170== 4,883,404 bytes in 9,613 blocks are still reachable in loss record 15 of 15
> ==20170== at 0x48CF308: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
> ==20170== by 0x804EE8B: xmalloc (xfuncs_printf.c:47)
> ==20170== by 0x806EC96: stalloc (ash.c:1417)
> ==20170== by 0x806ED00: stzalloc (ash.c:1434)
> ==20170== by 0x8071A22: expandarg (ash.c:7271)
> ==20170== by 0x8071ADE: expredir (ash.c:8666)
> ==20170== by 0x8073455: evaltree (ash.c:8401)
> ==20170== by 0x80744D2: evalloop (ash.c:8534)
> ==20170== by 0x8073546: evaltree (ash.c:8454)
> ==20170== by 0x8074916: cmdloop (ash.c:12185)
> ==20170== by 0x80761ED: ash_main (ash.c:13224)
> ==20170== by 0x804E143: run_applet_no_and_exit (appletlib.c:755)
>
> This is after a few seconds of execution. With more execution
> time, this number of blocks increases rapidly, and so is the
> process memory size.
>
> Without redirection this piece is not growing.
>
> Thanks,
>
> /mjt
Using the above info and digging into ash.c a little, I wrote a patch
that seems to fix it for my test case. If someone could review it and
see if it is OK or if there is a better way that would be great.
thanks,
Jon
["free_expanded_redir.patch" (text/plain)]
diff --git a/shell/ash.c b/shell/ash.c
index 010924d..617b5bf 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8676,6 +8676,8 @@ expredir(union node *n)
#if ENABLE_ASH_BASH_COMPAT
store_expfname:
#endif
+ if(redir->nfile.expfname)
+ stunalloc(redir->nfile.expfname);
redir->nfile.expfname = fn.list->text;
break;
case NFROMFD:
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic