Skip site navigation (1)Skip section navigation (2)
Date:      23 Oct 2000 02:29:32 -0400
From:      Arcady Genkin <antipode@thpoon.com>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Too many open files in system
Message-ID:  <87zojw9ik3.fsf@tea.thpoon.com>
In-Reply-To: <14835.26280.803484.793146@guru.mired.org>
References:  <14835.26280.803484.793146@guru.mired.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Mike Meyer <mwm@mired.org> writes:

> I don't have the lsof man page installed, but it may be counting every
> occurence of a shared file descriptor, whereas kern.maxfiles counts
> the actual open file descriptors. Try checking kern.openfiles.

Indeed, Vic Abell, the author of lsof, sent me an exerpt from the lsof
FAQ, which I include below for the benefit of the list.  (I hope Vic
doesn't mind, but since it's only a section of the FAQ...)

---------8<---------------8<-------------

Lsof should not be used to calculate the maximum number of open
files on a system without some careful scripting.  Read the lsof
FAQ file, 00FAQ, for an explanation --

3.17	Why is `lsof | wc` bigger than my system's open file limit?

	There is a strong temptation to count files by piping lsof
	output to wc.  If your purpose is to compare the number
	you get to some Unix system parameter that defines the
	number of open files your system can have, resist the
	temptation.

	One reason is that lsof reports a number of "files" that
	don't occupy Unix file table space -- current working
	directories, root directories, text files, library files,
	memory mapped files are some.  Another reason is that lsof
	can report a file shared by more than one process that
	itself occupies only one file table slot.

	If you want to know the number of open files that occupy
	file table slots, use the +ff option and process the lsof
	output's FILE_ADDR column information with standard Unix
	tools like cut, grep, sed, and sort.

	You might also consider using use lsof's field output with
	+ff, selecting the file struct address with -FF, and
	processing the output with an AWK or Perl script.  See the
	list_fields.awk and list_fields.perl scripts in the scripts/
	subdirectory of the lsof distribution for hints on file
	struct post-processing filters.

-- 
Arcady Genkin
Don't read everything you believe.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87zojw9ik3.fsf>