From owner-freebsd-questions@FreeBSD.ORG Sun Aug 17 22:39:44 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 950681065671 for ; Sun, 17 Aug 2008 22:39:44 +0000 (UTC) (envelope-from freebsd@t41t.com) Received: from rcpt.cat.pdx.edu (unknown [IPv6:2610:10:20:208:2e0:81ff:fe5c:af2e]) by mx1.freebsd.org (Postfix) with ESMTP id 7462F8FC16 for ; Sun, 17 Aug 2008 22:39:43 +0000 (UTC) (envelope-from freebsd@t41t.com) Received: from nemo.ece.pdx.edu (root@nemo.ece.pdx.edu [131.252.209.162]) by rcpt.cat.pdx.edu (8.13.8/8.13.8/Debian-2) with ESMTP id m7HMdeeh022725 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 17 Aug 2008 15:39:40 -0700 Received: from nemo.ece.pdx.edu (tait@localhost [127.0.0.1]) by nemo.ece.pdx.edu (8.13.6/8.13.1) with ESMTP id m7HMdesn016772 for ; Sun, 17 Aug 2008 15:39:40 -0700 (PDT) Received: (from tait@localhost) by nemo.ece.pdx.edu (8.13.6/8.12.6/Submit) id m7HMddm7016771 for freebsd-questions@freebsd.org; Sun, 17 Aug 2008 15:39:39 -0700 (PDT) X-Authentication-Warning: nemo.ece.pdx.edu: tait set sender to freebsd@t41t.com using -f Date: Sun, 17 Aug 2008 15:39:39 -0700 From: Tait To: freebsd-questions@freebsd.org Message-ID: <20080817223939.GK20385@ece.pdx.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.7i X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (rcpt.cat.pdx.edu [131.252.208.107]); Sun, 17 Aug 2008 15:39:40 -0700 (PDT) X-Spam-Status: No, score=2.2 required=6.0 tests=FAKE_REPLY_C autolearn=no version=3.2.1 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.2.1 (2007-05-02) on rcpt.cat.pdx.edu X-Virus-Scanned: ClamAV 0.92.1/7983/Fri Aug 8 11:20:42 2008 on rcpt.cat.pdx.edu X-Virus-Status: Clean Subject: Re: Max. number of opened files, efficiency X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Aug 2008 22:39:44 -0000 > How many files can I open under FreeBSD, at the same time? > ... > I tried to open 1000 temporary files and I could do so within one second. > > Another interesting (offtopic) question is that I could not open 10 000 > files under Windows XP. Error was "too many open file". How to overcome > this? The maximum number of files is controlled by kern.maxfilesperproc in /etc/sysctl.conf. It appears (on my 7.0 system) that the default is 2599. The maximum number of files per process for Windows XP is controlled in stdio.h and is set to 512 (with three eaten by stdin/stdout/stderr). On earlier versions of Windows, this number was much lower. The way to "overcome" this is almost always to redesign your program. You're not spawning 1000 threads (I hope) to write to every file simultaneously, so you can probably move the open/write/close-file inside your 1-to-1000 for loop and only need one file open at once, which is much more reasonable. If the size of your temporary files is small, you might look at using in-memory variables instead of files. Tait