X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:from:to:subject:date:message-id:references
	:in-reply-to:content-type:content-transfer-encoding
	:mime-version; q=dns; s=default; b=xyCiPX51w7k3A3NxeYGE4bKzeKCV5
	396ZDyQHjchv8i+3yKH0/toJwsIKbIBxYkEqggrBqoYQZ9IXAR4VSCw3fXMCrNRX
	4s7aFHDObmO1NhR6gXqJ9SDmIffA5Lw+fhM9YO2vKm49TKE0haXTa1KIbiy/MudM
	HC9GQz8po7VBkg=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:from:to:subject:date:message-id:references
	:in-reply-to:content-type:content-transfer-encoding
	:mime-version; s=default; bh=UpLsV6rpX8QlFB0yyYBoT8FYEuY=; b=QDf
	cX053KcxAAqAh8+9W+AuN0OUt7yFY5RwINM9iUp0JfAJQ19N+j6h9hUoJh+Vdipp
	yNsNnRhWQv6Zp35mnU+g0PmIeoNiBzhmFniCEzFOICFkvNlupLlWYZRy2wx7P+vq
	83z/jJsNIuzC3Lh56BQxvAZNrKV+hrQdUb1CqrNY=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=1.9 required=5.0 tests=AWL,BAYES_50,MIME_BASE64_BLANKS,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2
X-HELO: livemail.shubertorg.com
From: Doug Lewan <dougl@shubertticketing.com>
To: =?utf-8?B?UGV0ciBUaXTEm3Jh?= <petr@titera.eu>,
        "cygwin@cygwin.com"	<cygwin@cygwin.com>
Subject: RE: Possible resource leak
Date: Tue, 9 Dec 2014 15:30:43 +0000
Message-ID: <155DEC68569B714B86C2C7075F5EDA9892B9D411@DAKIYA1.pegasus.local>
References: <5486B88D.1040303@titera.eu>
In-Reply-To: <5486B88D.1040303@titera.eu>
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
X-IsSubscribed: yes
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id sB9FV9ou029115

Petr,

You write:
> -----Original Message-----
> Subject: Possible resource leak
> 
> I'm dealing with possible resource leak in cygwin on Windows-7. I'm
> running a script which repeatedly calls another script (every 5
> seconds). After a while script ends with memory error. All my memory
> seems to be eaten by Page Table entries and in the memory map I see a
> lot of cygwin processes with 4 pages allocated (I can provide
> screenshot
> if neccessary). Is this known issue?

A few questions come to mind.

Can you tell which processes are staying around?
Use CYGWIN's ps(1); Window's Task Manager is likely to show only bash.exe.

Are you sure that all of wget(1)'s resources have been freed
before it gets invoked again?
It surely uses things (IP stack, IP connections for example) that the Windows kernel manages.
Similarly, sleep(1)'s main resource is interrupts, probably also eventually coming from the kernel.
Perhaps there's a lock you should check (or create).

You'll also be sleeping 0 seconds about every 5th cycle;
maybe you should sleep $(( RANDOM%5 + 1 )) to make sure some sleeping always happens.

Every call to fetchData.sh is another fork()/exec() 
which has to re-establish the definitions of getFileNoCheck() and getFileCheck().
It might be better to put everything into main.sh.

Just some quick thoughts. It's always possible that there is something deep and subtle
inside the CYGWIN DLL happening. (But I doubt it.)



