# A question about ROOT

**URL:** <https://root-forum.cern.ch/t/a-question-about-root/62617>\
**Category:** ROOT\
**Tags:** python, hist\
**Created:** [January 9, 2025, 1:57pm UTC](https://root-forum.cern.ch/t/a-question-about-root/62617 "2025-01-09T13:57:47Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [January 10, 2025, 4:34am UTC](https://root-forum.cern.ch/t/a-question-about-root/62617/5 "2025-01-10T04:34:12Z")

</div>

Great, thanks for sharing!

The problem is because you’re having a bunch of TFiles opened, and any newly created histogram is automatically owned by the currently-opened file. At the end of the Python process (in this case your `exit()`), the ROOT objects are deleted in a random order, and if the histogram is deleted after the file there will be an invalid memory access and a crash.

We’ll avoid this problem in the next ROOT release by telling PyROOT that is should not delete these histograms created by `Clone()` itself.

For now, the workaround is to manually unset the owning directory of these histograms:

```python
new_iso_tight.SetDirectory(ROOT.nullptr)

```

---

_[View the full topic](https://root-forum.cern.ch/t/a-question-about-root/62617)._
