# Memory reduction when loading ROOT RDataFrame in python

**URL:** <https://root-forum.cern.ch/t/memory-reduction-when-loading-root-rdataframe-in-python/64395>\
**Category:** Newbie\
**Tags:** rdataframe, python\
**Created:** [November 12, 2025, 9:58am UTC](https://root-forum.cern.ch/t/memory-reduction-when-loading-root-rdataframe-in-python/64395 "2025-11-12T09:58:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tancredi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tancredi/32/20395_2.png) [@tancredi](https://root-forum.cern.ch/u/tancredi)\
**Post date:** [November 12, 2025, 9:58am UTC](https://root-forum.cern.ch/t/memory-reduction-when-loading-root-rdataframe-in-python/64395/1 "2025-11-12T09:58:50Z")

</div>

* * *

_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:_ Not Provided  
_Platform:_ lxplus  
\*Compiler:\*gcc 13.1

1. 
* * *

When working with python and RDataFrame one often has the problem that a large amount of memory is used. In particular, when using cling and C++ functions that are not precompiled. In this contest I was wondering why a simple ROOT import does already take 600 Mbyte and if there is a way to reduce it. I run my jobs on the grid where I read in a tree and create histograms. So I do not need any graphics etc.. Together with MakexAODDataFrame I start with 1 Gbyte of memory just loading the libraries. This is prohibitive for grid jobs since often the sites have only 2 Gbyte.  
Could one have a root light version for such applications ?

The attached files is a simple example of how much memory is used using ROOT in python  
Thank you for your help.

[test.py](https://root-forum.cern.ch/uploads/short-url/pstNLD25E4NvXUDsq3hFRL2K5zr.py) (994 Bytes)

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [November 12, 2025, 10:26am UTC](https://root-forum.cern.ch/t/memory-reduction-when-loading-root-rdataframe-in-python/64395/2 "2025-11-12T10:26:13Z")

</div>

Maybe @vpadulan or @Danilo can comment on this.  
And BTW, FWIW, I see less memory usage on Windows:

```auto
C:\root-dev\rootdev>python test.py
print_memory: print_memory Starting: Print memory consumption:
print_memory: Resident memory: 294.953125 MB
print_memory: Virtual memory : 168.81640625 MB

```

---

<div class="post-metadata">

**Author:** ![tancredi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tancredi/32/20395_2.png) [@tancredi](https://root-forum.cern.ch/u/tancredi)\
**Post date:** [November 12, 2025, 11:20am UTC](https://root-forum.cern.ch/t/memory-reduction-when-loading-root-rdataframe-in-python/64395/3 "2025-11-12T11:20:02Z")

</div>

Just a clarification.

On lxplus vanilla  
print\_memory: print\_memory Starting: Print memory consumption:  
print\_memory: Resident memory: 285.37890625 MB  
print\_memory: Virtual memory : 384.734375 MB

After  
setupATLAS  
asetup AnalysisBase,25.2.45

print\_memory: print\_memory Starting: Print memory consumption:  
print\_memory: Resident memory: 455.78515625 MB  
print\_memory: Virtual memory : 564.23046875 MB

The larger memory was using a docker image of AnalysisBase on my laptop

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [November 12, 2025, 5:59pm UTC](https://root-forum.cern.ch/t/memory-reduction-when-loading-root-rdataframe-in-python/64395/4 "2025-11-12T17:59:25Z")

</div>

Dear @tancredi,

Thanks for reaching out to the forum!

One possible source of discrepancy between the two environments is that in the ATLAS environment many more libraries are loaded by default by AnalysisBase, because they are needed for the rest of ATLAS processing. One starting point to look into this could be running `ROOT.gSystem.ListLibraries()` in both environments and see the differences.

I see the potential issue with this, clearly we always strive to be as lightweight as possible, I’m sure that improvements are always possible.

Cheers,

Vincenzo

---

<div class="post-metadata">

**Author:** ![tancredi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tancredi/32/20395_2.png) [@tancredi](https://root-forum.cern.ch/u/tancredi)\
**Post date:** [November 12, 2025, 8:38pm UTC](https://root-forum.cern.ch/t/memory-reduction-when-loading-root-rdataframe-in-python/64395/5 "2025-11-12T20:38:30Z")

</div>

Yes, the ATLAS libraries add as well. We probably should work on both. However, for ROOT is there a way to have a light weight version, e.g. that does not use graphic libraries ?

I also noticed that when writing in-time compiled code in python/RDataFrame the memory usage increases a lot. Here, I could make use of pre-compiled code. I am still wondering why this is so memory-heavy.  
Tancredi
