This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Shell script loop runs out of memory
- From: AZ 9901 <az9901 at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 31 May 2012 20:16:22 +0200
- Subject: Re: Shell script loop runs out of memory
- References: <loom.20120531T193933-322@post.gmane.org>
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