Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Too many open files error

 
swapnel surade
Ranch Hand
Posts: 129
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm getting one java exception when I run my application on linux terminal.
It showing me the exception as "Too many open files . Error : 24".
Its File descriptor error. I dont know how to tackle this issue.
If anybody knows about this error please help me.

thanks
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try to increase the number of file descriptors. The syntax is

 
swapnel surade
Ranch Hand
Posts: 129
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried that also but its not working as after some time that error occurs.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're probably just leaking file descriptors. Make sure you close every file you open when you're done with it.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest Friedman-Hill wrote:You're probably just leaking file descriptors. Make sure you close every file you open when you're done with it.


And that includes doing the close in a "finally" clause if there's a possibility that an exception would occur that would cause the normal close to be bypassed. I've run into systems that leaked slowly because MOST of the time, execution proceeded normally, but occasional exceptions would leak resources.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was reviewing some code the other day by a junior developer that simply didn't close files at all. On questioning, it turned out he figured the garbage collector would do it.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest Friedman-Hill wrote:I was reviewing some code the other day by a junior developer that simply didn't close files at all. On questioning, it turned out he figured the garbage collector would do it.


I forgive him (her?). The early docs made such a big thing about how Java collects garbage. And as a pioneer vendor of C++, I'd gotten accustomed to having destructors do exactly that.

However, I got assigned to fix a project that was, in fact, leaking resources (network connections, actually), and now I know better.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic