Error Code 24 - Too many open files?

I’m doing some extensive testing of a recent build of one of my apps and I’m getting error code 24 when I try to attempt to open a TCP socket or read a TextInputStream. Looking up this error code online shows the description as Too Many Open Files.

I’m kinda stumped as to what would cause this and how to prevent it. I’ve never seen this before.

Anyone have any ideas?

Oh, yeah, I’m running OS X.

call SetMaximumOpenFileCountMacOSXMBS with e.g. 10000.