# Bad Allocation Error looping though TTree

**URL:** <https://root-forum.cern.ch/t/bad-allocation-error-looping-though-ttree/53911>\
**Category:** ROOT\
**Tags:** tree\
**Created:** [March 7, 2023, 10:49am UTC](https://root-forum.cern.ch/t/bad-allocation-error-looping-though-ttree/53911 "2023-03-07T10:49:25Z")\
**Posts on this page:** 1\
**Showing post:** 26

<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:** [March 8, 2023, 8:32am UTC](https://root-forum.cern.ch/t/bad-allocation-error-looping-though-ttree/53911/26 "2023-03-08T08:32:27Z")

</div>

I don’t think this is a proper approach.  
You should pass appropriate (Windows specific) flags to the compiler. I guess @bellenot can help with this.

An example (note that the “debug” and C++ standard flags must correspond to your ROOT binary distribution):

> [@On Visual Studio 2022 Root running problem](https://root-forum.cern.ch/t/on-visual-studio-2022-root-running-problem/53636/2):
>
> Welcome to the ROOT Forum! Make sure you build with the same flags than the ones used to build ROOT. Since you only have one source file, I would suggest to build in the x64 Native Tools Command Prompt for VS 2022. Something like this: cl -nologo -MD -GR -EHsc -Zc:\_\_cplusplus -std:c++17 RooPlot.cxx -I %ROOTSYS%\include /link -LIBPATH:%ROOTSYS%\lib libCore.lib libGui.lib libHist.lib libGpad.lib And if you want your program (your TCanvas) to stay open, you have to add an instance of TApplicatio…

---

_[View the full topic](https://root-forum.cern.ch/t/bad-allocation-error-looping-though-ttree/53911)._
