Re: Creating C++ objects from PyRoot/GaudiPython vs. from C++

From: <wlavrijsen_at_lbl.gov>
Date: Fri, 25 Feb 2011 13:14:01 -0800


Brett,

> The "DayaBay.__init__" doesn't apparently have a "_creates" member:

which version of ROOT are you using? I'm guessing it's "too old." Actually, _creates is even older than having it work with constructors, which was its own can of worms.

>> Additional options are to tell the function that stores the object into the
>> store that it should take ownership rights, or setting ownership on the
>> python object directly.
>
> I can explore this. Do you have some pointers?

Assuming that the version you use is new enough, each method has a _mempolicy member which can be set similarly to the global one. The other option is the use of SetOwnership(). See here:

   http://wlav.web.cern.ch/wlav/pyroot/memory.html

>> Note that GaudiPython has a different memory policy by default then
>> does ROOT.
>
> Okay. Is this something I need to understand to solve this problem?

Maybe ... With "heuristics" memory policy, if an object is passed through a non-const pointer function argument, it is considered owned by C++ after that. ROOT is very consistent in its interfaces, which is why that works. Not so in Gaudi, so there the policy is "strict."

What I'm thinking of, is if the object is passed to C++ for adding it to the event store, that it passes through a function that takes a non-const pointer to it. Then, if the _mempolicy of that function is set to ROOT.kMemoryHeuristics, ownership would always be given up.

Best regards,

            Wim

-- 
WLavrijsen_at_lbl.gov    --    +1 (510) 486 6411    --    www.lavrijsen.net
Received on Fri Feb 25 2011 - 22:14:18 CET

This archive was generated by hypermail 2.2.0 : Sat Feb 26 2011 - 05:50:01 CET