Memory/other limiting factor

My program finds 72 .root files and is supposed to operate on all of them. However, it suddenly stops, usually around the 21st file. I thought maybe there was a limit to how much could be printed to the terminal, but after removing the histogram::fit output, it still got cut short. There is no error message or stack trace, it just suddenly stops and quits root:
image
Could this be a problem with memory?

ROOT Version: 6.18/04
Platform: Windows
Compiler: Not Provided


It can be some variables allocated on the stack, which is limited. It’s better to allocate them on the heap.

How can I do that? I looked it up and it seems I should use * pointers instead of variables, but it seems like most of my stuff is already declared as pointers

Then try to start your program from the debugger. To do so, first open a x86 Native Tools Command Prompt for VS 2019, cd to C:\Users\klin\SNOLAB\rat and type:

C:\Users\klin\SNOLAB\rat>devenv /debugexe yourapp.exe

I see this memory spike image
This is what the rest looks like


What can I do with this?

I see there is an unhandled exception. If you want to try to catch it, you must use the debug version of ROOT and build your app (and anything you want to debug) in debug mode…

Can you explain how to do that? Currently I ran the command you gave me, pressed the start button in VS, and then ran my macro in the terminal that appeared

Which version of ROOT did you install? How did you compile your application?

Root 6.18/04 for Windows. The “application” is a macro. I run it by using “.x macro.cc” in the root terminal, where it is then compiled by root (I think)

OK, so download the debug version of ROOT 6.18/04 for Windows, and use ACLiC to debug your macro .x macro.cc++

For anyone else with this issue, the fix was to do “garbage collection” aka
delete graph
delete hist
at the end of functions so that there isn’t allocated memory being kept for no reason.
Deleting trees crashes the macro and deleting some other stuff crashes it too so its best to test deleting root objects individually