# RDataFrame: TH1DModel tricks to use less memory

**URL:** <https://root-forum.cern.ch/t/rdataframe-th1dmodel-tricks-to-use-less-memory/53553>\
**Category:** Newbie\
**Created:** [February 9, 2023, 3:22pm UTC](https://root-forum.cern.ch/t/rdataframe-th1dmodel-tricks-to-use-less-memory/53553 "2023-02-09T15:22:36Z")\
**Posts on this page:** 2\
**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:** [February 9, 2023, 3:22pm UTC](https://root-forum.cern.ch/t/rdataframe-th1dmodel-tricks-to-use-less-memory/53553/1 "2023-02-09T15:22:37Z")

</div>

Hello,  
I use RDataFrame in my analysis and I have a large number of systematic uncertainties (O(1500)). I implemented them via the Vary Method.

> code:  
> model= ROOT.RDF.TH1DModel(‘hname’,‘Title’, len(ptbins[0])-1, ptbins[0])  
> d.Vary(ptvar, method, variationTags=vtags, variationName=“pt” ).Histo1D(model,ptvar,‘weight’))

This works great !  
Unfortunately now my memory blows up and I can not run the code. Are there some tricks to use less memory. For the good old TH1D for example one can switch to TH1F or remove the sumw2 option which reduces already a lot…  
Thank you for your help.  
Tancredi

---

<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:** [February 9, 2023, 7:22pm UTC](https://root-forum.cern.ch/t/rdataframe-th1dmodel-tricks-to-use-less-memory/53553/2 "2023-02-09T19:22:02Z")

</div>

Hello @tancredi ,

the simplest thing to do is use coarser binning. You can also split your 1500 histograms in 2 separate loops, which halves the memory usage. Or reduce the number of thread (the number passed to `EnableImplicitMT(n)` which will also scale down memory usage accordingly.

I hope this helps,  
Enrico
