# Root file size question

**URL:** <https://root-forum.cern.ch/t/root-file-size-question/11758>\
**Category:** ROOT\
**Created:** [January 27, 2011, 5:18am UTC](https://root-forum.cern.ch/t/root-file-size-question/11758 "2011-01-27T05:18:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![has64](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/76d3ee/32.png) [@has64](https://root-forum.cern.ch/u/has64)\
**Post date:** [January 27, 2011, 5:18am UTC](https://root-forum.cern.ch/t/root-file-size-question/11758/1 "2011-01-27T05:18:53Z")

</div>

Hi I am using root v5.27/04 on SL5, I have two root files with lots of subdirectories (about 100). Both files have similar histograms inside(about 4 histograms in each subdirectory). Recently I noticed one root file’s size became extremely large (about 1GB) while the other one is only about 1MB. I am wondering is there a method to test which subdirectory in the first file takes so much size? I believe there must be something wrong with the first file. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [January 27, 2011, 5:23pm UTC](https://root-forum.cern.ch/t/root-file-size-question/11758/2 "2011-01-27T17:23:42Z")

</div>

Hi,

Check the result of myfile-\>Map(). Check the result of myfile-\>ls();

Philippe.

---

<div class="post-metadata">

**Author:** ![has64](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/76d3ee/32.png) [@has64](https://root-forum.cern.ch/u/has64)\
**Post date:** [January 27, 2011, 5:45pm UTC](https://root-forum.cern.ch/t/root-file-size-question/11758/3 "2011-01-27T17:45:03Z")

</div>

Thanks for you help, I tried myfile-\>Map() for both files, the file with small size looks reasonable but the larger one reads as following (I only show the last part of the results):

20101209/114959 At:177837 N=359 TH1F CX = 8.53  
20110119/141016 At:178196 N=343 TDirectory  
20110119/145334 At:178539 N=73 TDirectory  
20110119/145336 At:178612 N=73 TDirectory  
20110119/145458 At:178685 N=129 TDirectory  
Address = 178814 Nbytes = -68 =====G A P===========  
20110119/141827 At:178882 N=73 TDirectory  
20110119/145444 At:178955 N=129 TDirectory  
Address = 179084 Nbytes = -322830265 =====G A P===========  
20110119/145444 At:323009349 N=1 END

It looks like the last GAP taks so much space, can I figure out how to deal with the Gap? Also the actual file size is 1085924891 (1.1 GB) rather than 323009349 (0.3 GB), any possible reason for this? Thank you for your help!

[quote=“pcanal”]Hi,

Check the result of myfile-\>Map(). Check the result of myfile-\>ls();

Philippe.[/quote]

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [January 27, 2011, 6:11pm UTC](https://root-forum.cern.ch/t/root-file-size-question/11758/4 "2011-01-27T18:11:29Z")

</div>

Hi,

No, it seems odd. Something must have gone wrong when writing the file.

Cheers,  
Philippe.

---

<div class="post-metadata">

**Author:** ![has64](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/76d3ee/32.png) [@has64](https://root-forum.cern.ch/u/has64)\
**Post date:** [January 27, 2011, 11:32pm UTC](https://root-forum.cern.ch/t/root-file-size-question/11758/5 "2011-01-27T23:32:28Z")

</div>

OK, thanks a lot though… I think it is caused during writting/deleting .

[quote=“pcanal”]Hi,

No, it seems odd. Something must have gone wrong when writing the file.

Cheers,  
Philippe.[/quote]

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [January 27, 2011, 11:39pm UTC](https://root-forum.cern.ch/t/root-file-size-question/11758/6 "2011-01-27T23:39:56Z")

</div>

Hi,

Humm … Is this reproducible? Do you store something ‘temporarily’ in the file? Is there any TTree involved? What is your code looking like?

Philippe.

---

<div class="post-metadata">

**Author:** ![has64](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/76d3ee/32.png) [@has64](https://root-forum.cern.ch/u/has64)\
**Post date:** [January 28, 2011, 12:03am UTC](https://root-forum.cern.ch/t/root-file-size-question/11758/7 "2011-01-28T00:03:14Z")

</div>

Hi, I am not sure I can reproduce it because I wrote to the root file over the past 3 months using different scripts. And I think it happened recently. There is no temporary or TTree in the file.

Several days ago, right after I created 10 subdirectories and wrote some histograms in the file, and then using TBrowser to look at the histograms. Odd thing was when I click dir1 through dir5, an error message like the one in [Error in ReadBasketBuffers & Gaps with Map()](https://root-forum.cern.ch/t/error-in-readbasketbuffers-gaps-with-map/10226/1) happened (I don’t remember exactly the error message, but it looks like the same) , while dir6 through dir10 works fine.

I then deleted dir1 through dir5, and then wrote them again. Now the error message appeared when I use TBrowser to click dir6 through dir10, while dir1 through dir5 works fine . Noted that now dir6 through dir10 appeared before the new dir1 through dir5 in the root file, I suspected that any directory in there will have that error. My naive solution is to delete dir1 through dir10 first, created 5 empty directories which I won’t use (hoping they could occupy the space that may cause error), then write dir1 through dir10 again. Now the problems is solved. But no more error when I click the empty directories.

I am not sure whether this is related to the sudden change of the file size, but it is really odd to me.

[quote=“pcanal”]Hi,

Humm … Is this reproducible? Do you store something ‘temporarily’ in the file? Is there any TTree involved? What is your code looking like?

Philippe.[/quote]

---

<div class="post-metadata">

**Author:** ![has64](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/76d3ee/32.png) [@has64](https://root-forum.cern.ch/u/has64)\
**Post date:** [January 28, 2011, 12:13am UTC](https://root-forum.cern.ch/t/root-file-size-question/11758/8 "2011-01-28T00:13:51Z")

</div>

Hi, I was trying to run the tutorial copyFile Code as in [root.cern.ch/root/html/tutorials … les.C.html](http://root.cern.ch/root/html/tutorials/io/copyFiles.C.html)  
I only changed the root file name that to be copied as in Line 70 to 73. For the normal root file, this code works fine. But for the extremely large root file, after copying some subdirectories, an error like following appear:

KEY: TH1F v2\_CtauE\_frac\_dt;2 v2\_CtauE\_frac\_7\<v2\_Pt\<7.5 GeV/c  
KEY: TH1F v2\_CtauE\_frac\_dt;1 v2\_CtauE\_frac\_7\<v2\_Pt\<7.5 GeV/c  
Error: Symbol #include is not defined in current scope copyFiles.C:43:  
Error: Symbol exception is not defined in current scope copyFiles.C:43:  
Syntax Error: #include copyFiles.C:43:  
Error: Symbol G\_\_exception is not defined in current scope copyFiles.C:43:  
Error: type G\_\_exception not defined FILE:/export/home/has64/hepserv01\_repos/BcJpsiPi/./copyFiles.C LINE:43  
\*\*\* Interpreter error recovered \*\*\*

Any suggestions? Thanks a lot!

[quote=“pcanal”]Hi,

Humm … Is this reproducible? Do you store something ‘temporarily’ in the file? Is there any TTree involved? What is your code looking like?

Philippe.[/quote]

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [March 1, 2011, 8:49pm UTC](https://root-forum.cern.ch/t/root-file-size-question/11758/9 "2011-03-01T20:49:17Z")

</div>

[quote]But for the extremely large root file[/quote]Is it large because there there is many histograms and is it large because there are trees. If it is because of many histograms, you are probably running out of memory and might need to explicitly delete the histogram after copying them. If it is because of large TTree, you may need to prevent them from closing the file if it reach the size ‘limit’ by setting the size limit very very high (See TTree::SetMaxTreeSize).

Cheers,  
Philippe.

PS. You can also try running your example under valgrind (and/or gdb) to see more information about the problem.
