0 and 1′s

lsof and Unclosed file handlers

Posted in J2EE, Java, unix by Rama Krishna on August 26, 2009

After checking out a blog entry about analyzing Classpath of a running Java program by Thilina Mahesh Buddhika, i decided to try the command on the Java Web server used at my organization. To my surprise, i was able to find unclosed file handlers in the application hosted on the Web server.

drawer_metal_drawers_281984_l

The command lsof -p lists all open sockets, files and pipes. By analyzing the output of the command, i was able to check all the files opened by the application and able to reason why it was open by going through the application code. This also helped me in fixing unclosed file handlers.

Try out the command and try figuring out why the files are referred to. This gives an insight to functioning of the application.

Check out the usage of the command @ following link http://sial.org/howto/debug/unix/lsof/

Reblog this post [with Zemanta]
Tagged with: , , ,
Follow

Get every new post delivered to your Inbox.