« Return to Thread: Shell script loop runs out of memory

Re: Shell script loop runs out of memory

by AZ 9901 :: Rate this Message:

| View in Thread

2012/5/31 Jordan :
> I am just wondering why the loops here are consuming increasing amounts of
> memory over time?  I'm assigning new MD5 values into existing variables over and
> over, not allocating new variables for each MD5 assignment. (Right??) Is 1
> second perhaps too short a delay... does the system need time to deallocate
> something between each iteration of the inner loop?
>
You are certainly under effect of BLODA.
You could have a look (there is a BLODA section in Cygwin online doc).

Then, when (bash) scripting under Cygwin, you must take care to avoid
forking as much as possible.

You could try to improve the "sleep 1" loop with the following one :

while md5sum $FILE_TO_CHECK | cut -d " " -f1 | grep -q "^$MD5PRINT$"
do
  sleep 1
done

Note that MD5PRINTNEW is no more useful here.
With this loop we avoid the fork done by
MD5PRINTNEW=`md5sum $FILE_TO_CHECK | cut -d " " -f1`

Ben

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

 « Return to Thread: Shell script loop runs out of memory