Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging the "Too many files open" issue

The application i am working on suddenly crashed with

java.io.IOException: ... Too many open files

As i understand the issue it means that files are opened but not closed.

Stacktrace of course happens after the fact and can only help understand before what event error occurred.

What would be an intelligent way to search your code base to find this issue which only seems to occur when app is under high stress load.

like image 990
James Raitsev Avatar asked Apr 11 '13 15:04

James Raitsev


1 Answers

  1. use lsof -p pid to check what cause leak of file references;

  2. use ulimit -n to see the limit of opened file references of a single process;

  3. check any IO resources in your project,are they released in time?,Note that,File,Process,Socket(and Http connections) are all IO resources.

  4. sometimes, too many threads will cause this problem too.

like image 147
BlackJoker Avatar answered Sep 28 '22 05:09

BlackJoker