• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Networking framework crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Networking framework crash
      • From: Jens Alfke <email@hidden>
    • Re: Networking framework crash
      • From: Michael Nickerson <email@hidden>
References: 
 >Networking framework crash (From: Graham Cox <email@hidden>)
 >Re: Networking framework crash (From: Alex Zavatone <email@hidden>)
 >Re: Networking framework crash (From: Graham Cox <email@hidden>)
 >Re: Networking framework crash (From: Michael Nickerson <email@hidden>)

  • Prev by Date: Re: NSCalendar and NSDates prior to October 15, 1582
  • Next by Date: Re: Networking framework crash
  • Previous by thread: Re: Networking framework crash
  • Next by thread: Re: Networking framework crash
  • Index(es):
    • Date
    • Thread