> On Feb 5, 2015, at 10:22 AM, Roland King <r...@rols.org> wrote: > > >> >> 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. >
Well, that'll teach me to double check before posting. I hadn't realized the max got upped. Seems like it's 2560 (I would guess it's higher when run in Xcode for debugging). > 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. > Makes sense to me. I have run up against the max open files limit before when it was still 256. I am happy to see it was raised. > launchctl limit shows > > maxfiles 256 unlimited > > That’s the only place I can find 256 and I don’t know when that is used. > So, I take the above back - not running into the limit, unless maybe it's being run by launchd. Those limits shown by launchctl are what's used by anything launchd launches, unless the plist file overrides them. I wonder if that's on purpose or just an oversight? And yes, I tested that this time! I get: Feb 5 11:16:46.875 test[4252]: cur: 2560 Feb 5 11:18:00.078 test[4274]: cur: 256 (First is normal run, second is launched by launchd.) ________________________ Michael Nickerson _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com