# Out of memory when ROOT does not have permission to write to a directory

**URL:** <https://root-forum.cern.ch/t/out-of-memory-when-root-does-not-have-permission-to-write-to-a-directory/52801>\
**Category:** Newbie\
**Tags:** root\
**Created:** [December 16, 2022, 5:18pm UTC](https://root-forum.cern.ch/t/out-of-memory-when-root-does-not-have-permission-to-write-to-a-directory/52801 "2022-12-16T17:18:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jocl](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jocl/32/35197_2.png) [@jocl](https://root-forum.cern.ch/u/jocl)\
**Post date:** [December 16, 2022, 5:18pm UTC](https://root-forum.cern.ch/t/out-of-memory-when-root-does-not-have-permission-to-write-to-a-directory/52801/1 "2022-12-16T17:18:44Z")

</div>

Hi all,

No code here, but I am wondering about some behavior I observed.

I have a compiled program which uses ROOT - the actual content of the program is not particularly important to the behavior, but it reads from a TTree, generates some random numbers on top of the TTree, and writes the new TTree to file.

Normally, when calling `TTree::Fill`, the basket is flushed at 32k of memory usage. However, it looks to me like when the program does not have permission to write to a certain file, the basket is never flushed, and data is held in memory indefinitely. No error is generated for being unable to access/write to the file.

When this happens, eventually I run out of memory and the process is killed by the kernel.

When I execute the program with a directory to which it has permissions to write, everything works fine, and memory usage stays low.

I’ve resolved the issue by changing the permissions of the directory, but now I am curious if this is the expected behavior. Could an error message/exception be added, or is there some reason (either due to C++ or ROOT) that it can’t?

Thanks!

_ROOT Version:_ 6.22  
_Platform:_ Ubuntu 22.04 LTS  
_Compiler:_ g++

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [December 16, 2022, 5:29pm UTC](https://root-forum.cern.ch/t/out-of-memory-when-root-does-not-have-permission-to-write-to-a-directory/52801/2 "2022-12-16T17:29:23Z")

</div>

Try:

```cpp
TFile *f = TFile::Open("/cannot/write/file.root", "recreate");
if (!f || f->IsZombie()) { std::cout << "ERROR\n"; return; }

```
