Debug for "Too many open files"

Need help with C, C++, perl, python, etc?

Debug for "Too many open files"

Postby I am a nobody » 2017-04-19 10:08

Hi,

I need to check and fix "Too many open files" caused by bugs of TCP sockets were opened but not closed. What is the command line I can check how many socket file descriptors have been opened?

Thank you.
I am a nobody
 
Posts: 39
Joined: 2012-04-13 03:44

Re: Debug for "Too many open files"

Postby dasein » 2017-04-19 15:11

And the search query you used before you posted is... what exactly?

I got some great results using tcp socket "too many files"
User avatar
dasein
 
Posts: 7768
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Debug for "Too many open files"

Postby GarryRicketson » 2017-04-19 15:49

You can try this:
Code: Select all
cat /proc/sys/fs/file-max

For system wide limits
'ulimit'
Is a useful command
Code: Select all
man ulimit

--Try :
Code: Select all
ulimit -n


There is a file : 'limits.cnf' in /etc/security/
that can be modified.
Since you do not mention what version of Debian you are using, the above might not apply, I am using Debian 7 wheezy, and it is a valid command.
The Debian wiki,is often a valuable resources ?
https://wiki.debian.org/Limits
Also :
https://manpages.debian.org/jessie/libpam-modules/limits.conf.5.en.html
User avatar
GarryRicketson
 
Posts: 4117
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Debug for "Too many open files"

Postby I am a nobody » 2017-04-19 21:53

GarryRicketson wrote:You can try this:
Code: Select all
cat /proc/sys/fs/file-max

For system wide limits
'ulimit'
Is a useful command
Code: Select all
man ulimit

--Try :
Code: Select all
ulimit -n


There is a file : 'limits.cnf' in /etc/security/
that can be modified.
Since you do not mention what version of Debian you are using, the above might not apply, I am using Debian 7 wheezy, and it is a valid command.
The Debian wiki,is often a valuable resources ?
https://wiki.debian.org/Limits
Also :
https://manpages.debian.org/jessie/libpam-modules/limits.conf.5.en.html


Thanks all responses. It is Debian 8 Jessie, Sorry for not clear here, my intention is to debug a C++ program socket library which I suspect it might not close the socket properly. I need to run command to check how many socket descriptor files have been opened while I am running a test program to start the socket application and close it in a loop until it crashes the machine by error "Too many open files". So I am looking for the command line to display how many socket descriptor files are opened. I figured out that the lsof is the right command.

Thank you.
I am a nobody
 
Posts: 39
Joined: 2012-04-13 03:44

Re: Debug for "Too many open files"

Postby Bulkley » 2017-04-20 01:45

Is this a school project?

Have you mixed anything with your Jessie that does not belong? Added extra repositories? ppa's? Messed with something you shouldn't have?

Sorry for asking but this seems rather strange.
Bulkley
 
Posts: 5235
Joined: 2006-02-11 18:35

Re: Debug for "Too many open files"

Postby dasein » 2017-04-20 13:03

I am a nobody wrote:Sorry for not clear here...

You were perfectly clear. You wanted to count the number of open TCP sockets, not to identify a maximum limit. Unfortunately, poster clarity doesn't always guarantee on-topic responses.

I am a nobody wrote:my intention is to debug a C++ program socket library...

As a pure question of economy of effort, I'd encourage you to focus on your own code first. (And if the socket library is your own code, then have at it.)

I am a nobody wrote:...start the socket application and close it in a loop until it crashes the machine

Purely pedantic point: abnormal termination of an application is not "crashing the machine" nor anywhere close to it.

I am a nobody wrote:I figured out that the lsof is the right command.

It's certainly a workable solution.
User avatar
dasein
 
Posts: 7768
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Debug for "Too many open files"

Postby Dai_trying » 2017-04-20 14:52

You could simply open a terminal and type
Code: Select all
netstat -an | grep -i tcp | wc -l
you could even put it in a loop to keep updating at an interval of your choosing.
Dai_trying
 
Posts: 297
Joined: 2016-01-07 12:25


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

fashionable