too many files open and questions


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users too many files open and questions
# 1  
Old 12-28-2003
too many files open and questions

Hi all,

Presently I'm using a 3pp that uses fopen to open files and I encounter this problem of too many files open when it is trying to open a file. My application is done in java which interfaces with this 3pp. When I instantiate this 3pp it loads up some files but it is pops up the error saying that there are too many files open. However, right after that i try opening a file in my own application and it has no problems. Some of the questions that I have is:

1) Is there a way to know what files are open on a certain pid?
2) What exactly does pfiles pid show? Does it show the number of files that are open for tht particular pid?
3) file descriptors are used when files are opened but are there any other cases when file descriptors are used? (i.e. corba calls, commands such as ping, etc)
4) is there any way to increase a soft limit? I've already increased the hard limit to over 32k.
5) could the result of a truss with many EBADF represent anything related to this problem?

BTW this is executed on a Solaris 8 platform.

Any help would be greatly appreciated.

-lmcanth
# 2  
Old 12-29-2003
For (1) you can use lsof, like

lsof -p 1445

lists the files held open by pid 1445.
# 3  
Old 12-29-2003
I answer this with some trepidation since I have no idea what a 3pp is.


2 Like lsof, it shows the file descriptors in use. That is not the same thing as the number of files open.

3. ping is a program and it uses file descriptors. It would not be reasonable to write a program that uses ping in such a way as consume it's own file descriptors, but unreasonable programmers exist. And there are many other ways to allocate a file descriptor. dup()/fcntl() may rival or even surpass open()/creat(). Network connections use file descriptors. lsof will tell you what each file descriptor is doing. It really is the tool of choice.

4. setrlimit() When a program needs a lot of fd's but didn't call setrlimit, it must be considered "broken". Most likely it is leaking fd's.

5. Well I guess that even if the truss was performed years ago on another system and on an unrelated process, it is possible that the output of the truss does represent something that is related to this problem.
# 4  
Old 12-31-2003
btw 3pp = 3rd party product.

I've tried lsof but it does not seem to work. Any clues?
# 5  
Old 12-31-2003
What is the default limit for the user in question? Use ulimit -n to see.

You can change the soft limit for the user by adding ulimit -n <some number> to the user's .profile or the script that is starting your process. You will not be able to set the limit above the system hard limit.

Cheers,

Keith
# 6  
Old 12-31-2003
I spoke to the 3pp and they use fopen frequently in their C code. However there is a limit to the soft limit and it can only go up to 255.

http://cvs.sourceforge.net/viewcvs.p...olaris?rev=1.6

This link details this.

We have quite a few Corba objects that are open, could it be possible that these objects are using up the soft limit resources?

In that case, even if it is set to 255 we can easily reach this limit right?
# 7  
Old 12-31-2003
You are getting two different things mixed up. The max of a soft limit is the hard limit. On SunOS 5.8 I just observed that, for file descriptors, my hard limit was 1024 and my soft limit was 256. I raised my soft limit to 512. I am using ksh which has a builtin ulimit. Switch to ksh and try it:
ulimit -n
ulimit -Hn
ulimit -Sn 512
ulimit -n

At this point I can open 512 files in a single process. But I'll admit that I've never tried to write such a program.

The next thing is how many files can stdio manage. I must admit that I was skeptical about the information in the link you provided. But "man stdio" not only backs it up, but points out that things are a tad worse...
Quote:
Note that no more than 255 files may be opened using fopen(), and only file descriptors 0 through 255 can be used in a stream.
That means that cranking the fd's up to 512 may not help much. And you may not reach 255 fopened files because a few fd's were burned for other things.

HP's docs claim that you can fopen() as many files as you have fd's. But I have never verified that.

It's hard to answer your question about "easily" reaching 255. I have never come close to that. I continue to suspect that your "3pp" is leaking fd's. Since you seem to have support, I would follow up with the vendor.

lsof works fine for me on SunOS 5.8. "I've tried lsof but it does not seem to work." is not much to go on. The best I can do with that is say "you must be doing something wrong." If you were to post a few more details, maybe someone can help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Process to use open files

I would like to test open files usage in my system, if I want to create a process ( or script ) that can use a certain amount ( eg. 1000 ) of open files , is it possible to create such process ( or script ) ? (3 Replies)
Discussion started by: ust
3 Replies

2. Shell Programming and Scripting

Flagging Open Files

A quick breakdown of my situation: I have 2 servers running OS 10.7, one in the US, the other in China. A folder is being synchronized via EMC's "Syncplicity". Here is my problem- When we open an Excel spreadsheet on one server, Syncplicity does not sync over the temporary file that Excel... (0 Replies)
Discussion started by: sudo
0 Replies

3. Shell Programming and Scripting

Compare files questions

Hello, I have two files A and B. File A had a million records with each record been 10-digit number. File B had 400,000 records with each record been 10-digit number. There are some common and different records. I need to print out records in A that are not in B. Please assist. Thanks - jak (5 Replies)
Discussion started by: jakSun8
5 Replies

4. Shell Programming and Scripting

open files

I want to open a file and edit it using vi However, i dont want to open directories or binary files. how can i do this? Right now it opens all files without caring echo "please enter a file to edit in Vi" read file if then (2 Replies)
Discussion started by: icelated
2 Replies

5. Homework & Coursework Questions

Print questions from a questions folder in a sequential order

1.) I am to write scripts that will be phasetest folder in the home directory. 2.) The folder should have a set-up,phase and display files I have written a small script which i used to check for the existing users and their password. What I need help with: I have a set of questions in a... (19 Replies)
Discussion started by: moraks007
19 Replies

6. Solaris

Sun Open Storage Questions

Hey All, I had some minor questions regarding Sun's open storage I understand it uses standard industry hardware (is the warranty void if we were to mix and match drives?) I know it uses OpenSolaris for the storage features (but can it use any os?) Does it have to be OpenSource? I... (7 Replies)
Discussion started by: Keepcase
7 Replies

7. UNIX for Dummies Questions & Answers

cat multiple files questions

Hi-- I'm trying to figure out how to use cat more wisely. I have the following command, which works, but I'd like to understand how to get it to work more clearly and efficiently. cat 'my file.001' 'my file.002' 'my file.003' 'my file.004' 'my file.005' 'my file.006' 'my file.007' 'my... (6 Replies)
Discussion started by: rlinsurf
6 Replies

8. Solaris

Newbie questions about HOME directory files

Hi, I am newbie to Solaris and system administration in general, and I have a couple of questions about files in my HOME directory. When I perform ls -la, I get the following list of files: drwxr-xr-x 7 XXXYYY staff 17 Aug 24 07:31 . drwxr-xr-x 7 root root 7... (2 Replies)
Discussion started by: JVerstry
2 Replies

9. UNIX for Advanced & Expert Users

Too Many files open

Hi , We are using a Tool which runs on Unix Server. Have a Event which have some join operation and tries to open files depending on the join operation. So get the error config/variants/orcl6/partitions/ml6/data/ap_PCardMap.csv (Too many open files) Can someone please... (3 Replies)
Discussion started by: shashank_recj
3 Replies

10. Solaris

How to check no. of files open currently

I'm getting an error "too many files open" # ulimit -a time(seconds) unlimited file(blocks) unlimited data(kbytes) unlimited stack(kbytes) 8192 coredump(blocks) unlimited nofiles(descriptors) 256 memory(kbytes) unlimited # hard limit shows 1024 I would like to know how many files... (1 Reply)
Discussion started by: max_min
1 Replies
Login or Register to Ask a Question