From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30952 invoked by alias); 1 Jun 2012 10:32:27 -0000 Received: (qmail 30863 invoked by uid 22791); 1 Jun 2012 10:32:06 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.83/v0.83-20-g38e4449) with ESMTP; Fri, 01 Jun 2012 10:31:51 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 02CE32C007B; Fri, 1 Jun 2012 12:31:48 +0200 (CEST) Date: Fri, 01 Jun 2012 10:32:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Shell script loop runs out of memory Message-ID: <20120601103148.GB28506@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2012-06/txt/msg00009.txt.bz2 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