From owner-freebsd-questions@FreeBSD.ORG Wed Aug 13 14:44:14 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 CC1641065671 for ; Wed, 13 Aug 2008 14:44:14 +0000 (UTC) (envelope-from gandalf@shopzeus.com) Received: from viefep11-int.chello.at (viefep11-int.chello.at [62.179.121.31]) by mx1.freebsd.org (Postfix) with ESMTP id 296CC8FC1D for ; Wed, 13 Aug 2008 14:44:13 +0000 (UTC) (envelope-from gandalf@shopzeus.com) Received: from [192.168.1.103] (really [89.134.230.13]) by viefep11-int.chello.at (InterMail vM.7.08.02.02 201-2186-121-104-20070414) with ESMTP id <20080813144406.QFDI25278.viefep11-int.chello.at@[192.168.1.103]>; Wed, 13 Aug 2008 16:44:06 +0200 Message-ID: <48A2F335.6010206@shopzeus.com> Date: Wed, 13 Aug 2008 16:44:05 +0200 From: Laszlo Nagy User-Agent: Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: Bill Moran , freebsd-questions@freebsd.org References: <48A2EBD7.9000903@shopzeus.com> <20080813103244.d9c76715.wmoran@potentialtech.com> In-Reply-To: <20080813103244.d9c76715.wmoran@potentialtech.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: 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: Wed, 13 Aug 2008 14:44:14 -0000 > Directories generally start to perform poorly when you put too many files > in them (i.e. the time required to add a new directory entry or find > an existing name in the entry goes up) > > If you're going to be making 10s of 1000s of files, I'd recommend making > a tree of directories. I.e., make directories 1 - 10, then put files > 0-999 in directory 1 and files 1000-1999 in directory 2, etc > In fact I do not need any name associated with the file. I just need a temporary file object, I would like to access it in read write mode and then throw it. For some reason, this kind of temporary file is implemented this way (at least in Python): 1. create file name with mkstemp 2. create file object with that name 3. save the file handle number 4. unlink the file name (remove directory entry) 5. return the file handle (that can be closed later) This is executed each time I create a temporary file. As you can see, the number of entries in the tmp directory won't increase at all. (If it would be possible, I would create a file without a name for the first time.) When I close the file handle, the OS will hopefully deallocate the disk space because from that point, nothing references the file. 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? Thanks, Laszlo