# Long time to close ROOT file with O(500k) histograms

**URL:** <https://root-forum.cern.ch/t/long-time-to-close-root-file-with-o-500k-histograms/44229>\
**Category:** ROOT\
**Tags:** io, hist\
**Created:** [March 30, 2021, 3:14pm UTC](https://root-forum.cern.ch/t/long-time-to-close-root-file-with-o-500k-histograms/44229 "2021-03-30T15:14:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rustem](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/c0e974/32.png) [@rustem](https://root-forum.cern.ch/u/rustem)\
**Post date:** [March 30, 2021, 3:14pm UTC](https://root-forum.cern.ch/t/long-time-to-close-root-file-with-o-500k-histograms/44229/1 "2021-03-30T15:14:39Z")

</div>

Hello,

I am trying to write an output ROOT file using the attached macro that contains O(500k) histograms. I see that TFile.Close() function takes a very long time even after the file is written. You can reproduce this with this command:

$ python processHitInfo.py data18\_v6.root --save-hists

where the input file is available here:

[https://rustem.web.cern.ch/debug/data18\_v6.root](https://rustem.web.cern.ch/debug/data18_v6.root)

Please let me know if you cannot reproduce this or have any questions. Thanks for taking a look.

Cheers,  
Rustem

[processHitInfo.py](https://root-forum.cern.ch/uploads/short-url/4yfGzHMNFNED1Zsi3I8yXgkIUBr.py) (13.1 KB)

* * *

_Please read [tips for efficient and successful posting](https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292) and [posting code](https://root-forum.cern.ch/t/posting-code-read-this-first/28293)_

_ROOT Version:_ v6.20.06  
_Platform:_ lxplus  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![oshadura](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oshadura/32/14460_2.png) [@oshadura](https://root-forum.cern.ch/u/oshadura)\
**Post date:** [March 31, 2021, 7:30am UTC](https://root-forum.cern.ch/t/long-time-to-close-root-file-with-o-500k-histograms/44229/2 "2021-03-31T07:30:20Z")

</div>

@pcanal can you please take a look?Thanks!

---

<div class="post-metadata">

**Author:** ![oshadura](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oshadura/32/14460_2.png) [@oshadura](https://root-forum.cern.ch/u/oshadura)\
**Post date:** [March 31, 2021, 7:32am UTC](https://root-forum.cern.ch/t/long-time-to-close-root-file-with-o-500k-histograms/44229/3 "2021-03-31T07:32:51Z")

</div>

@rustem I think it could be a valid ROOT bug, can you please open a bug report at [Issues · root-project/root · GitHub](https://github.com/root-project/root/issues)  
Thanks!

---

<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 31, 2021, 2:38pm UTC](https://root-forum.cern.ch/t/long-time-to-close-root-file-with-o-500k-histograms/44229/4 "2021-03-31T14:38:11Z")

</div>

To speed up the process and _if_ you are sure that there is no reference to the histogram that need to be indirectly cleaned-up (eg. if you close any Canvases prior to the file closing), you can do:

```auto
ROOT.gROOT.GetListOfFiles().Remove(myfile)

```

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [April 14, 2021, 2:38pm UTC](https://root-forum.cern.ch/t/long-time-to-close-root-file-with-o-500k-histograms/44229/5 "2021-04-14T14:38:23Z")

</div>

Closed on April 14, 2021, 2:38pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
