Fix crashes when loading large .qmlproject's (Mac OS X)

There is a hard limit on the number of file handles that can be open at one point per process on Mac OS X (e.g. it's 2560 on Mac OS X Snow Leopard Server, as shown by ulimit -a). Opening one or several .qmlproject's with a large number of directories to watch easily exceeds this. The results are crashes later on, e.g. when threads cannot be created any more.

This patch implements a heuristic that the file system watcher used for .qmlproject files never uses more than half the number of available file handles. It also increases the number from rlim_cur to rlim_max - the old code in main.cpp failed, see last section in

 http://developer.apple.com/maac/library/documentation/Darwin/Reference/ManPages/man2/setrlimit.2.html

for details.

Reviewed-by: ckamm
Task-number: QTCREATORBUG-1487
Task-number: QTCREATORBUG-1486
This commit is contained in:
Kai Koehne
2010-05-28 13:45:53 +02:00
parent 3082395c14
commit 7f1f9e14af
2 changed files with 37 additions and 1 deletions

View File

@@ -173,7 +173,8 @@ int main(int argc, char **argv)
// increase the number of file that can be opened in Qt Creator.
struct rlimit rl;
getrlimit(RLIMIT_NOFILE, &rl);
rl.rlim_cur = rl.rlim_max;
rl.rlim_cur = qMin((rlim_t)OPEN_MAX, rl.rlim_max);
setrlimit(RLIMIT_NOFILE, &rl);
#endif