Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A fix for 'Too many open files' in bittorrent apps Apps
Some large bittorrent files will be composed of hundreds of smaller .rar files. If the total number of files in a torrent is over 256, OS X bittorrent applications will fail with the "too many open files" error. This is because by default, OS X applications have a maximum limit of 256 open files. To get around this, in a terminal type:
ulimit -n 2000
Use 2000 or some other suitably large number. Then launch your bittorrent application from the same terminal window by cd'ing into the package, etc. Note that this will not work unless your application is launched from the same terminal.

There is probably a way to insert the ulimit statement into a logon script so that the effect is systemwide, but as of yet I haven't figured it out.
    •    
  • Currently 3.50 / 5
  You rated: 5 / 5 (4 votes cast)
 
[25,600 views]  

A fix for 'Too many open files' in bittorrent apps | 10 comments | Create New Account
Click here to return to the 'A fix for 'Too many open files' in bittorrent apps' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A fix for 'Too many open files' in bittorrent apps
Authored by: dotjamie on Oct 07, '04 12:50:15PM

This is horrible advice.

Changing a ulimit in a shell will only affect other processes launched by that shell after the ulimit was put in.

So, if you launch from Finder, your ulimit wont do anything.

This is what you should do.

Edit (or create) /etc/sysctl.conf

In it put:

#
# allow system to run more processes
kern.maxproc=2048
# allow users to run more processes
kern.maxprocperuid=500

.. then reboot.

I still havent figured out the problem tho where the entire system hangs after 256 simultaneous streams are running. Bleah.



[ Reply to This | # ]
A fix for 'Too many open files' in bittorrent apps
Authored by: ParadisePete on Oct 07, '04 05:23:29PM
This is horrible advice.
Horrible?

Changing a ulimit in a shell will only affect other processes launched by that shell after the ulimit was put in.

Well ya know, he already said that. His 'horrible' comment does exactly what he said it does, and nothing more.

[ Reply to This | # ]

A fix for 'Too many open files' in bittorrent apps
Authored by: cewatts on Oct 07, '04 07:49:28PM

This isn't good advice either. kern.maxproc controls the maximum number of running processes, not the maximum number of open files per proc.

The more appropriate sysctls to looks at would be kern.maxfiles and kern.maxfilesperproc, but on my system (1GB ram, probably autoscaled) they default quite high: kern.maxfiles = 12288, kern.maxfilesperproc = 10240.

A system-wide shell limit change (as the other posts suggest) is what is necessary, unless I'm missing something.



[ Reply to This | # ]
A fix for 'Too many open files' in bittorrent apps
Authored by: osxpounder on Oct 11, '04 04:05:09PM

It might seem like a good idea to start a post with a warning like, "This is horrible advice", but it generates some unintended results.

After all, the original poster was trying to help, and didn't intend to give "horrible advice". Calling their advice horrible not only hurts their feelings, but makes you sound arrogant--neither of which contribute to our goals here: sharing advice, reviewing it, improving it. You could make an enemy without even intending to, or knowing you did.

Instead, consider saying, "Here's an alternative that's better, and here's why: ....." That way, you don't say anything negative about the other person's post, but you do get to say all kinds of positives about your own. The advice is the point, not whether you think it's good, bad or stinky.

---
--
osxpounder



[ Reply to This | # ]
A fix for 'Too many open files' in bittorrent apps
Authored by: mikeg_us on Oct 07, '04 12:59:07PM
Use sysctl to set kern.maxfiles to a number larger than 256.
http://www.osxfaq.com/man/8/sysctl.ws

Mike Gray


[ Reply to This | # ]
A fix for 'Too many open files' in bittorrent apps
Authored by: pope_cerebus on Oct 07, '04 01:17:50PM

To do this system wide, the easiest way is to edit the file /etc/bashrc (as root) and add your 'ulimit -n 1024' line at the end.

For csh users add 'limit descriptors 1024' to /etc/csh.cshrc (or maybe /etc/csh.login). For csh you can use 'limit descriptors unlimited' which will set it to the hard system limit.

AFAIK the 'sysctl' sets the hard (max) limits which you may not want to change. The 'ulimit' and 'limit' command set the soft limits (for normal users) so are more appropriate.

Cerebus



[ Reply to This | # ]
A fix for 'Too many open files' in bittorrent apps
Authored by: _merlin on Oct 07, '04 07:23:54PM

Won't work, because we usually launch things from the Finder, not from a shell.



[ Reply to This | # ]
A fix for 'Too many open files' in bittorrent apps
Authored by: pope_cerebus on Oct 08, '04 08:54:26AM

Possibly , I haven't tested it.

Though the Finder is owned by the user, so must be launched with the user's system limits. If this is set system wide, then it should apply to all applications no matter how they are launched.

You would have to login again to see if it made a difference.

Cerebus



[ Reply to This | # ]
This is the way Apple wants you to do it
Authored by: rhowell on Oct 07, '04 08:35:52PM
I found this article on Apple's developer pages:

Setting environment variables for user processes

which describes how to make a .plist file containing your environment variables, and naming the file

~/.MacOSX/environment.plist

[ Reply to This | # ]
A fix for 'Too many open files' in bittorrent apps
Authored by: HyperSeeker on Oct 08, '04 12:39:40AM

Azureus (http://azureus.sf.nt)

In v2.0.4, it has an option under Configuration > Files > Performance Options, you can specify the maximum number of files open/read, maximum outstand disc block writes, and maximum check pieces.

Simple and effective. Also check out some of Azureus plugin. Very useful.

---
"At my signal, unleash hell" -Maximus



[ Reply to This | # ]