delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/12/13/12:31:51

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <47616D31.7090002@4raccoons.com>
Date: Thu, 13 Dec 2007 09:34:41 -0800
From: Wayne Christopher <wayne AT 4raccoons DOT com>
User-Agent: Thunderbird 1.5.0.4 (X11/20060516)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: VM and non-blocking writes
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

I have a server application that runs on XP under the latest cygwin, 
that opens up a socket connection to a client on another system, makes 
that socket non-blocking using fcntl(.... O_NDELAY), and then feeds the 
client a large file (100's of MBs) by doing the following:

1. call write() with the entire size of the data not yet written

2. the return value of write is the number of bytes actually written 
(should be limited by the socket buffer size - it is on linux)

3. select() for writable status on the socket (and do other things in 
the mean time)

4. when the socket becomes writable, goto 1

What I see is that no matter how large the size is that I give to 
write(), the return value is always the full size.  Also, I see the 
virtual memory used by my process go way up - in fact it goes up by much 
more than the amount of data I've written.

I tried putting in a limit of 10KB in the size given to the write() 
call.  I still see the VM size grow - more slowly this time, but it 
eventually reaches 1.5GB and then I'm out of memory.

Has anybody seen this behavior?  Should I not be using O_NDELAY?  Any 
other workarounds?

I don't have a simple example program but I can make one if that will help.

Thanks,

    Wayne

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019