[Top][All Lists]

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

Re: Unexpected delay in using arguments.

From: Bob Proulx
Subject: Re: Unexpected delay in using arguments.
Date: Tue, 14 Aug 2018 15:50:36 -0600
User-agent: Mutt/1.10.1 (2018-07-13)

I followed along through the script:

>     m=20000
>     test1() { ...

Eventually I got to this line:

>       set -- $(seq $m)

At that line I see that bash must allocate enough memory to hold all
of the numbers from 1 through 20000 in memory all at one time.  That
is very inefficient.  That is at least 100K of memory.

  $ seq 20000 | wc -c

Of course I assume this is only a proxy simpler reproducer for the
actual problem program but just the same it is almost always possible
to refactor a program into a different algorithm that avoids the need
to enumerate so many arguments in memory.  I suggest refactoring the
program to avoid the need for this memory stress.


reply via email to

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