# Memory leak when processing RDataFrames in python loop

**URL:** <https://root-forum.cern.ch/t/memory-leak-when-processing-rdataframes-in-python-loop/51170>\
**Category:** ROOT\
**Tags:** rdataframe\
**Created:** [August 12, 2022, 1:51pm UTC](https://root-forum.cern.ch/t/memory-leak-when-processing-rdataframes-in-python-loop/51170 "2022-08-12T13:51:23Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [August 12, 2022, 5:52pm UTC](https://root-forum.cern.ch/t/memory-leak-when-processing-rdataframes-in-python-loop/51170/4 "2022-08-12T17:52:27Z")

</div>

Hi @asopio ,

without a complete minimal reproducer that I can run, my guess is that the memory hogging comes from the code for the `Filter` expression that (in ROOT v6.18) is re-compiled at every loop (see e.g. [How to delete RDataFrame and clean up memory - #2 by eguiraud](https://root-forum.cern.ch/t/how-to-delete-rdataframe-and-clean-up-memory/33036/2) ). Code that is just-in-time-compiled stays in memory until the end of the application. The amount of code generated at every new loop is much much smaller in more recent ROOT versions. Can you please try with ROOT v6.26.06? There should be a little increase, but nothing as dramatic as ~4MB per iteration.

Cheers,  
Enrico

---

_[View the full topic](https://root-forum.cern.ch/t/memory-leak-when-processing-rdataframes-in-python-loop/51170)._
