ROOT Version: 6.22/02
Platform: mac os 10.15.6 (catalina)
Compiler: cling
Hello! I’m trying to debug a script that i suspect has a memory allocation issue at runtime. I discovered from doing “root -h” that there’s an option to track memory usage and statistics by specifying the option “-memstat” in my command. So i’d try something like “root -l -q -memstat mymacro.C++” to do so, and my script won’t even compile, despite including TMemStat.h, and despite successful compilation when not trying to use the -memstat option.
So, i tried to do just “root -memstat” and this also does not work, i get the following output at my screen:
input_line_11:2:6: error: unknown type name ‘TMemStat’
new TMemStat("",100000,5000000);
^
root [0] .q
input_line_12:2:2: error: ‘TMemStat’ is not a class, namespace, or enumeration
TMemStat::Close()
^
input_line_12:2:2: note: ‘TMemStat’ declared here
I’ve tried googling to get help with this error message, but i haven’t found much. Is there something i’m doing wrong here? Is there any other way to track memory allocation+usage in root while using a specific script that compiles fine, but crashes at runtime?
The memstat feature apparently is not part of the ROOT built. You can verify it with root-config --features. If you compile ROOT yourself, you can enable TMemStat with cmake -Dmemstat=on.
@Axel Should memstat be built by default? And if it’s not built, should we remove the memstat option from root.exe?
Hello! just to follow up, indeed, if i type ‘root-config --features’, memstat is absent.
Though, to make it slightly more interesting, on a different machine/ROOT build i have, details:
ROOT Version: 6.08/02
Platform: mac os 10.11.6 (el capitan)
Compiler: cling
doing ‘root-config --features’ shows memstat in the list of available features on my install. however, trying to use the memstat option with “root -memstat” yields an instant bus error and crash as follows:
Well that’s certainly not nice. On the other hand both MacOS 10.11 and ROOT 6.08 are fairly old.
Feel free to open a new issue at github.com/root-project/root/issues if you think this is relevant.
About your underlying issue, namely a need to debug memory-related problems: valgrind might work better than TMemStat for certain problems. It’s a standard debugging tool. You can suppress known ROOT false positives when running valgrind on ROOT programs with