Problem: too many open files

Hello everybody,
I’m using ROOT (version 5.34) to open some files and refill a tree inside each one (file by file) following some specific criteria. The macro produces the waited results without errors and without complaining for some hundreds of files till it abruptly interrupts saying:

SysError in TFile::TFile: file 609_01_20140128_1.root can not be opened for reading (Too many open files)
SysError in TFile::TFile: file 609_01_20140128_1.root can not be opened for reading (Too many open files)
SysError in TFile::TFile: file 609_01_20140128_1.root can not be opened for reading (Too many open files)
SysError in TFile::TFile: file 609_01_20140128_1.root can not be opened (Too many open files)
Error: illegal pointer to class object file 0x0 220 /home/silvia/MARSLINK/macros/guardo.C:128:
*** Interpreter error recovered ***

The problem is not the specific file. I’ve already tried changing both the files and their order.
I’ve looked at the suggestions in old topics similar to mine but any solutions have till now solved my problem.
Has somebody any ideas?

Thank you very much for each type of help you’ll be able to give me!
Cheers, Silvia.

What is the output of ulimit -n ?

If it seems small, then try increasing (ulimit -n NEW_LIMIT)

[quote=“cozzyd”]What is the output of ulimit -n ?

If it seems small, then try increasing (ulimit -n NEW_LIMIT)[/quote]

Thank you very much for your hint cozzyd!
I’ve just tried with the command ulimit -n and the output is 1024. How can I increase it?

You said file by file. Do you really need them all open - thousands of files - at the same moment?
You know, in principle you can … close the file as soon as you are done with it :wink: