# File open limit?

**URL:** <https://root-forum.cern.ch/t/file-open-limit/6349>\
**Category:** ROOT\
**Created:** [April 10, 2008, 2:24am UTC](https://root-forum.cern.ch/t/file-open-limit/6349 "2008-04-10T02:24:40Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![erdosgrinl](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/erdosgrinl/32/11139_2.png) [@erdosgrinl](https://root-forum.cern.ch/u/erdosgrinl)\
**Post date:** [April 10, 2008, 2:24am UTC](https://root-forum.cern.ch/t/file-open-limit/6349/1 "2008-04-10T02:24:40Z")

</div>

Hello all,

I am running into some kind of a limit on the number of files that can be opened via TFile at a time. Here is a small example of what I mean:

1. create a lot of Root files

```auto
#!/usr/bin/perl

$file="length_cut_1.root";

for $i(0..300) {
system "cp $file ana\_$i.root";
}
```

1. Try to open them all at the same time

```auto
void testChain()
{
  const int NFILE = 300;
  TFile **farray=new TFile*[NFILE];
  
  char itemp[100];
  for(int i=0;i<NFILE;i++) {
    
    sprintf(itemp,"ana_%i.root",i);
    if(i%20==0)cout << " opening file: " << itemp << endl;
    //cout<<"The file is "<<itemp<<endl;
  
    farray[i]=new TFile(itemp);
 
  }
}
```

1. However, I get an error after the 220th file or so. Here is the actual message:

```auto
  chaining run with source data: ana_200.root
  chaining run with source data: ana_220.root
SysError in <TFile::TFile>: file ana_221.root can not be opened for reading (Too many open files)
SysError in <TFile::TFile>: file ana_222.root can not be opened for reading (Too many open files)
SysError in <TFile::TFile>: file ana_223.root can not be opened for reading (Too many open files)
SysError in <TFile::TFile>: file ana_224.root can not be opened for reading (Too many open files)
SysError in <TFile::TFile>: file ana_225.root can not be opened for reading (Too many open files)
SysError in <TFile::TFile>: file ana_226.root can not be opened for reading (Too many open files)
SysError in <TFile::TFile>: file ana_227.root can not be opened for reading (Too many open files)
SysError in <TFile::TFile>: file ana_228.root can not be opened for reading (Too many open files)
SysError in <TFile::TFile>: file ana_229.root can not be opened for reading (Too many open files)
SysError in <TFile::TFile>: file ana_230.root can not be opened for reading (Too many open files)
SysError in <TFile::TFile>: file ana_231.root can not be opened for reading (Too many open files)

etc... 
```

1. All I need is to have ~450 files open at the same time. Is there a switch I could turn on/off to achieve the desired affect. Here is the ouput for:

```auto
sysctl -a | grep files
kern.exec: unknown type returned
kern.maxfiles = 65536
kern.maxfilesperproc = 30720
```

Many thanks in advance  
erdos

OSX 10.4.11  
Root 5.18 (tried on 5.17.x, 5.16.x)  
macosx64

---

_[View the full topic](https://root-forum.cern.ch/t/file-open-limit/6349)._
