[Qt-interest] Too many files open error on Mac OS
Kai Koehne
kai.koehne at nokia.com
Wed Sep 29 10:27:50 CEST 2010
On 9/29/2010 7:42 AM, ext Serge wrote:
> Hello,
>
> My QT 4.5 GUI program opens a lot of files. On windows it is working
> fine, but on Mac OS it receives error - too many files open.
> If i type in bash:
>
> ulimit -n
> 256
>
> I found out how to fix it:
>
> echo limit maxfiles 2048 1000000> /etc/launchd.conf
> #reboot
> ulimit -n
> 2048
>
> I deliver program to users in dmg archive.
> They just mount it and launch program.
> It can be a problem for some of them to make such a tuning in bash.
>
> Can program itself increase number of files, it can open, without need
> to reboot?
main.cpp of QtCreator has following code to achieve this:
#ifdef Q_OS_MAC
// increase the number of file that can be opened in Qt Creator.
struct rlimit rl;
getrlimit(RLIMIT_NOFILE, &rl);
rl.rlim_cur = qMin((rlim_t)OPEN_MAX, rl.rlim_max);
setrlimit(RLIMIT_NOFILE, &rl);
#endif
Regards
Kai
--
Kai Koehne
Software Engineer
Nokia, Qt Development Frameworks
Nokia gate5 GmbH
Firmensitz: Invalidenstr. 117, 10115 Berlin, Germany
Registergericht: Amtsgericht Charlottenburg, Berlin: HRB 106443 B
Umsatzsteueridentifikationsnummer: DE 812 845 193
Geschäftsführer: Dr. Michael Halbherr, Karim Tähtivuori
More information about the Qt-interest-old
mailing list