Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Help: Too many files open

Thread view: 
Tyrone Showers - 18 Jun 2006 05:33 GMT
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?
IchBin - 18 Jun 2006 07:11 GMT
> 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-)
Tyrone Showers - 18 Jun 2006 14:29 GMT
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.

> > 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
[quoted text clipped - 25 lines]
> 'If there is one, Knowledge is the "Fountain of Youth"'
> -William E. Taylor,  Regular Guy (1952-)
Gordon Beaton - 19 Jun 2006 07:53 GMT
> 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

Signature

[  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

Tyrone Showers - 20 Jun 2006 05:58 GMT
Thanks for your answer.

> > The application runs on Linux and Windows.
>
[quoted text clipped - 16 lines]
>
> /gordon
Oliver Wong - 19 Jun 2006 19:00 GMT
> I would just like to know if  Java provides an API to determine your
> current
[quoted text clipped - 8 lines]
> 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
Tyrone Showers - 20 Jun 2006 05:58 GMT
Thanks for your answer.

> > I would just like to know if  Java provides an API to determine your
> > current
[quoted text clipped - 14 lines]
>
>     - Oliver
Fergus Gibson - 28 Jun 2006 11:41 GMT
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.