This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Shell script loop runs out of memory


On May 31 17:42, Jordan wrote:
> Hi folks,
> 
> I've written a shell script running under CygWin, the purpose of which is to 
> monitor a file for changes. If the MD5 hash fails to match the previous hash, it 
> will execute a command to process the file. I used a 1-second delay between 
> checks of the hash. This works great for several hours, but then gives an "out 
> of memory" error and actually brings Windows 7 to its knees.
> [...]
> Here is the script:
> ------------------------
> #!/bin/sh
> 
> FILE_TO_CHECK=/mypath/style.less
> 
> echo "Reading hash for $FILE_TO_CHECK with md5sum"
> MD5PRINT=`md5sum $FILE_TO_CHECK | cut -d " " -f1`
> 
> MD5PRINTNEW=$MD5PRINT
> 
> while [[ 1 = 1 ]]
> do
>         echo "Waiting for file to change..."
> 
>         while [[ "$MD5PRINT" = "$MD5PRINTNEW" ]]
>         do
>                 sleep 1
> 
>                 MD5PRINTNEW=`md5sum $FILE_TO_CHECK | cut -d " " -f1`
>         done
> 
>         echo "File was modified ... Running compiler..."
> 
>         /mypath/lessc $FILE_TO_CHECK /mypath/style.css -x
> 
>         echo "Reading hash for $FILE_TO_CHECK with md5sum"
>         MD5PRINT=`md5sum $FILE_TO_CHECK | cut -d " " -f1`
> 
>         MD5PRINTNEW=$MD5PRINT
> done
> ------------------------

I'm running your script with disabled "sleep 1" and disabled "/mypath/lessc"
for about half an hour now on W7.  Neither the system memory usage, nor
the process memory usage of the outmost shell, nor the handle count of
the outmost shell has changed during this time.

I'm running this under the last snapshot from http://cygwin.com/snapshots/ 
Either the bug is fixed there, or you're really under the influence of
some BLODA.  Did you even check for BLODA?  I didn't see a hint of that
in this thread.

Also, how often does the file change so that you have to run the
compiler?  Is the compiler a native or a Cygwin tool?  Does the memory
problem occur visibly in task manager?  All the time or only when the
compiler runs?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]