Re: Networking framework crash
Re: Networking framework crash
- Subject: Re: Networking framework crash
- From: Roland King <email@hidden>
- Date: Thu, 05 Feb 2015 23:22:00 +0800
>
> Everything is a file descriptor. Open files, sockets, loaded frameworks & bundles, even STDIN/OUT/ERROR.
>
> You can check if you're hitting the limit of file descriptors by (temporarily) raising the number you can have open with setrlimit(). If you raise it and your app stops crashing, then that's likely the culprit. I would guess so - the default max number you can have open is 256, and 0xfe lines up with that...
>
> If your app runs long enough before crashing, you can also use lsof in Terminal to see what your app has open.
>
Where do you get 256 from? I just inserted the following two lines of code into a random OSX GUI app and a command line tool I wrote, right after launch
struct rlimit file_limit;
getrlimit( RLIMIT_NOFILE, &file_limit );
For the GUI app I get
file_limit.rlim_cur = 9472
and for the command line I get
file_limit.rlim_cur = 7168
when run from Xcode or 2560 in either case when run from the command line or double-clicked from the finder.
all of which seems to indicate processes have plenty more than 256 file descriptors available by default. I thought 256 was left behind as a default long ago because it was way too small.
If I’m in a bash shell and run
ulimit -n
I get 2560
launchctl limit shows
maxfiles 256 unlimited
That’s the only place I can find 256 and I don’t know when that is used.
Finally
sysctl kern.maxfilesperproc
returns 10240 which I think is the absolute hard limit on the number of file handles any process can have available.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden