By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,607 Members | 1,650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,607 IT Pros & Developers. It's quick & easy.

Help: Too many files open

P: n/a
I have a problem of getting the error "too many files open" and would like
to trace my application. However, I have found nothing about how to display
the current number of open files. Does anyone know what code is used to get
the current number of open files?

Also, is there a way to determine the number of open database connections?
Jun 18 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Tyrone Showers wrote:
I have a problem of getting the error "too many files open" and would like
to trace my application. However, I have found nothing about how to display
the current number of open files. Does anyone know what code is used to get
the current number of open files?

Also, is there a way to determine the number of open database connections?

Most all Java IDE's will let you do debugging at the instruction level.
You may want to use it. To me that this sounds like a coding logic problem.

What OS are you running. JDK version? What file api's are you using?

For Database connections depends on how you are opening the
connection(s). Do you spawn threads that have their own connections?

For me, I need more information!

I did a quick Google for the error you are getting and came up with a
lot of hits. Can not determine what you are doing to indicate a match...

Google .. java too many files open

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________ ________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Jun 18 '06 #2

P: n/a
I am using JDK 1.4.

The application runs on Linux and Windows.

I do know how to debug. I am using Log4J to help in debugging.

I do know I have a logic problem.

I have searched Google for "Too many files Open" for days for a resolution.

I have all Stream commands surrounded by a try catch with a finally closing
the stream.

This is a massive application and the problem could be anywhere, hence the
reason for tracing. There is really no code to post, because I don't know
where the problem lies.

I would just like to know if Java provides an API to determine your current
level of Open files e.g.,

Files.getCurrentOpenCount();

or

DatabaseConnection.getCurrentConnectionCount();

And if Java does provide such methods, is there a way to force the JVM to
close these lingering Opens.


"IchBin" <we******@ptd.net> wrote in message
news:Ps********************@ptd.net...
Tyrone Showers wrote:
I have a problem of getting the error "too many files open" and would like to trace my application. However, I have found nothing about how to display the current number of open files. Does anyone know what code is used to get the current number of open files?

Also, is there a way to determine the number of open database connections?
Most all Java IDE's will let you do debugging at the instruction level.
You may want to use it. To me that this sounds like a coding logic

problem.
What OS are you running. JDK version? What file api's are you using?

For Database connections depends on how you are opening the
connection(s). Do you spawn threads that have their own connections?

For me, I need more information!

I did a quick Google for the error you are getting and came up with a
lot of hits. Can not determine what you are doing to indicate a match...

Google .. java too many files open

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________ ________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

Jun 18 '06 #3

P: n/a
On Sun, 18 Jun 2006 09:29:32 -0400, Tyrone Showers wrote:
The application runs on Linux and Windows.
[...]
And if Java does provide such methods, is there a way to force the
JVM to close these lingering Opens.


If you are holding references to these objects, the JVM cannot know
they are no longer necessary.

If you are no longer holding references to them, they may eventually
be garbage collected and finalized. Realize though that lack of file
descriptors will not trigger the garbage collector.

On Linux you can use lsof or do "ls -l" in /proc/<pid>/fd to see what
open descriptors any process is holding. You can also use ulimit to
raise the descriptor limit, but that's not a solution to the real
problem.

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Jun 19 '06 #4

P: n/a

"Tyrone Showers" <ow********@taliferro.com> wrote in message
news:1z*******************@bignews8.bellsouth.net. ..

I would just like to know if Java provides an API to determine your
current
level of Open files e.g.,

Files.getCurrentOpenCount();

or

DatabaseConnection.getCurrentConnectionCount();

And if Java does provide such methods, is there a way to force the JVM to
close these lingering Opens.


For your second question, the answer is "probably no". How would the JVM
differentiate between an open which is "lingering" and an open which is
"critical to the correct functioning of this application"?

- Oliver

Jun 19 '06 #5

P: n/a
Thanks for your answer.
"Oliver Wong" <ow***@castortech.com> wrote in message
news:pDBlg.70834$JX1.13708@edtnps82...

"Tyrone Showers" <ow********@taliferro.com> wrote in message
news:1z*******************@bignews8.bellsouth.net. ..

I would just like to know if Java provides an API to determine your
current
level of Open files e.g.,

Files.getCurrentOpenCount();

or

DatabaseConnection.getCurrentConnectionCount();

And if Java does provide such methods, is there a way to force the JVM to close these lingering Opens.
For your second question, the answer is "probably no". How would the

JVM differentiate between an open which is "lingering" and an open which is
"critical to the correct functioning of this application"?

- Oliver

Jun 20 '06 #6

P: n/a
Thanks for your answer.

"Gordon Beaton" <n.***@for.email> wrote in message
news:44********@news.wineasy.se...
On Sun, 18 Jun 2006 09:29:32 -0400, Tyrone Showers wrote:
The application runs on Linux and Windows.


[...]
And if Java does provide such methods, is there a way to force the
JVM to close these lingering Opens.


If you are holding references to these objects, the JVM cannot know
they are no longer necessary.

If you are no longer holding references to them, they may eventually
be garbage collected and finalized. Realize though that lack of file
descriptors will not trigger the garbage collector.

On Linux you can use lsof or do "ls -l" in /proc/<pid>/fd to see what
open descriptors any process is holding. You can also use ulimit to
raise the descriptor limit, but that's not a solution to the real
problem.

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e

Jun 20 '06 #7

P: n/a
Tyrone Showers wrote:
I have a problem of getting the error "too many files open" and would
like to trace my application. However, I have found nothing about
how to display the current number of open files.


It looks like there is no simple way to do what you'd like.

I'm assuming that the application does legitimately need to work with a
massive number of files. Is the application spawning threads which are
opening the files? If so, you might want to create a thread pool to do it
instead of spawning an unlimited number of threads.

With a thread pool, you could limit the number of concurrent threads to a
set figure and then have them work on a series of files until the job is
done. For example, you could have 100 threads working through 1000 files
instead of trying to open 1000 files simultaneously in 1000 threads. This
way, you'd avoid two possible limits in the JVM: number of open files and
number of concurrent threads.
Jun 28 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.