bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash keeps too much data in memory


From: Andreas Schwab
Subject: Re: bash keeps too much data in memory
Date: Thu, 13 Mar 2008 15:29:16 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (gnu/linux)

Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl> writes:

> Description:
>       bash sometimes keeps in memory everything it outputs with echo.
>
> Repeat-By:
>       create BIG text file, lots of lines, at least 100MB
>       do 
>       while read ll;do echo $RANDOM $RANDOM $ll;done <bigfile >outfile
>       then from other console observe how bash grows, will and with something
>       above filesize - which suggest it keeps in memory all it echoed.

Does this patch help?

---
 builtins/read.def |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Index: builtins/read.def
===================================================================
--- builtins/read.def.orig      2007-11-10 01:20:45.000000000 +0100
+++ builtins/read.def   2007-11-10 02:03:38.000000000 +0100
@@ -134,7 +134,7 @@ read_builtin (list)
   intmax_t intval;
   char c;
   char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
-  char *e, *t, *t1, *ps2;
+  char *e, *t, *t1, *t2, *ps2;
   struct stat tsb;
   SHELL_VAR *var;
 #if defined (ARRAY_VARS)
@@ -677,12 +677,14 @@ add_char:
   if (*input_string)
     {
       t1 = input_string;
-      t = get_word_from_string (&input_string, ifs_chars, &e);
+      t2 = get_word_from_string (&input_string, ifs_chars, &e);
       if (*input_string == 0)
-       input_string = t;
+       input_string = t2;
       else
        input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, 
saw_escape);
     }
+  else
+    t2 = NULL;
 #endif
 
   if (saw_escape)
@@ -696,6 +698,7 @@ add_char:
   stupidly_hack_special_variables (list->word->word);
   if (var)
     VUNSETATTR (var, att_invisible);
+  FREE (t2);
   xfree (orig_input_string);
 
   return (retval);

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]