Loading/unloading class as interpreted macro in cling multiple times

Hello,

I have two files, Foo_1.C and Foo_2.C, which contain a class definition w/ same name (Foo), but different initializers for their data members.

Then, in a python steering file (steering.py) I load the classes sequentially in cling as interpreted macros, and use another interpreted macro (printBar.C) to perform operations w/ the class members. In my simple example, this just prints the value of the data member bar of the Foo instance in question.

At the end of one iteration, I unload the macros using ROOT.gROOT.ProcessLine(".U ...").

What I observe is that the bar value that gets printed is always the one of the first class that’s been loaded in cling. It looks like despite the class being unloaded, cling doesn’t free stuff in memory as one would expect…

Can you tell me what is wrong with this workflow, and what suggestions you might have to make this work?

I attach the set of files for a minimal working example.

Many thanks in advance for the help.

Cheers, Marco

Foo_2.C (62 Bytes)
Foo_1.C (62 Bytes)
printBar.C (122 Bytes)
steering.py (272 Bytes)


ROOT Version: 6.14/06
Platform: Not Provided
Compiler: Not Provided


Hi Marco,

Unfortunately, unloading of defined entities in the interpreter does not work properly, as you could see.

If you want to have two implementations for the same class, you will have to give it different names and switch between those.

Enric

Hi Enric,

ugh, that’s unfortunate :frowning:

Will this be fixed eventually?

Cheers
Marco

Let me ask @Axel to answer this one.

Eventually yes… I am hoping that we can make progress this year, but I was hoping for that already last year :frowning: I know how crucial this is!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.