Date: Thu, 11 Jan 2001 15:05:29 -0500 From: "Brian J. McGovern" <bmcgover@cisco.com> To: hackers@freebsd.org Subject: Question about 'open' files.... Message-ID: <200101112005.f0BK5T406464@bmcgover-pc.cisco.com>
next in thread | raw e-mail | index | archive | help
I'm doing some tests for Greg on vinum (trying to crash it), and I've run across a problem that is not particular to vinum. I'm hoping someone can explain it to me and/or tell me how to work around it. Using the code fragment (note: The code I'm using is actually more complex, and checks for errors in opening, writing, etc, but I'm keeping it basic for the discussion): for (counter = 0; counter < 20000; counter++) { x = open(filename,O_CREAT | O_WRONLY); write(x, buffer, size); close(x); } I will run anywhere between 1-5 instances of the code loop above. After there are about 2050 files on the disk (it _appears_ to be variations of 2048, plus files already on the disk, . and .., etc.), the programs crash with "too many open files". The problem, in my mind, is that the files are _closed_ (not open). I'm curious if this is some type of accounting error on a per-login basis, or whether there is some type of garbage collection not happening. Typically, after all of the applications die with this error, if I immediately restart, they die pretty quickly. If I wait like 10+ seconds, they can run again, and generate the 2048+/- files again before dying, which leads me to believe its something to do with per-user accounting/garbage collection. I would be curious to understand this, and its impact, as this does not appear to be 'good' (tm) behavior, particularly if one wishes to run a program that opens and closes a lot of small files. I welcome any thoughts. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101112005.f0BK5T406464>