Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
PyROOT::TMemoryRegulator Class Referencefinal

Manages TObject-derived objects created in a PyROOT application.

This class is responsible to keep track of the creation of the objects that need further memory management within ROOT. The ClearProxiedObjects function is only called at PyROOT shutdown time. The CallCppyyRecursiveRemove is called as part of the global list of cleanups object destruction.

This class is intentionally not derived from TObject. See the PyROOT::RegulatorCleanup class for more info.

Note
This class is not thread-safe on its own. We create one thread-local object in PyROOTWrapper.cxx.

Definition at line 63 of file TMemoryRegulator.h.

Private Types

using ObjectMap_t = std::unordered_map< Cppyy::TCppObject_t, Cppyy::TCppType_t >
 

Private Member Functions

 TMemoryRegulator ()
 Constructor.
 
void CallCppyyRecursiveRemove (TObject *object)
 Get the class id of the TObject being deleted and run Cppyy's RecursiveRemove.
 
void ClearProxiedObjects ()
 Clean up all tracked objects.
 
std::pair< bool, boolRegisterHook (Cppyy::TCppObject_t, Cppyy::TCppType_t)
 Register a hook that Cppyy runs when constructing an object.
 
std::pair< bool, boolUnregisterHook (Cppyy::TCppObject_t, Cppyy::TCppType_t)
 Register a hook that Cppyy runs when deleting an object.
 

Private Attributes

ObjectMap_t fObjectMap {}
 

Friends

class RegulatorCleanup
 

#include </home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master/bindings/pyroot/pythonizations/src/TMemoryRegulator.h>

Member Typedef Documentation

◆ ObjectMap_t

Definition at line 64 of file TMemoryRegulator.h.

Constructor & Destructor Documentation

◆ TMemoryRegulator()

PyROOT::TMemoryRegulator::TMemoryRegulator ( )
private

Constructor.

Registers the hooks to run on Cppyy's object construction and destruction

Definition at line 21 of file TMemoryRegulator.cxx.

Member Function Documentation

◆ CallCppyyRecursiveRemove()

void PyROOT::TMemoryRegulator::CallCppyyRecursiveRemove ( TObject object)
private

Get the class id of the TObject being deleted and run Cppyy's RecursiveRemove.

Parameters
[in]objectObject being destructed.

Definition at line 69 of file TMemoryRegulator.cxx.

◆ ClearProxiedObjects()

void PyROOT::TMemoryRegulator::ClearProxiedObjects ( )
private

Clean up all tracked objects.

Definition at line 81 of file TMemoryRegulator.cxx.

◆ RegisterHook()

std::pair< bool, bool > PyROOT::TMemoryRegulator::RegisterHook ( Cppyy::TCppObject_t  cppobj,
Cppyy::TCppType_t  klass 
)
private

Register a hook that Cppyy runs when constructing an object.

Parameters
[in]cppobjAddress of the object.
[in]klassClass id of the object.
Returns
Pair of two booleans. First indicates success, second tells Cppyy if we want to continue running RegisterPyObject

Definition at line 35 of file TMemoryRegulator.cxx.

◆ UnregisterHook()

std::pair< bool, bool > PyROOT::TMemoryRegulator::UnregisterHook ( Cppyy::TCppObject_t  cppobj,
Cppyy::TCppType_t  klass 
)
private

Register a hook that Cppyy runs when deleting an object.

Parameters
[in]cppobjAddress of the object.
[in]klassClass id of the object.
Returns
Pair of two booleans. First indicates success, second tells Cppyy if we want to continue running UnRegisterPyObject

Definition at line 52 of file TMemoryRegulator.cxx.

Friends And Related Symbol Documentation

◆ RegulatorCleanup

friend class RegulatorCleanup
friend

Definition at line 78 of file TMemoryRegulator.h.

Member Data Documentation

◆ fObjectMap

ObjectMap_t PyROOT::TMemoryRegulator::fObjectMap {}
private

Definition at line 66 of file TMemoryRegulator.h.

  • bindings/pyroot/pythonizations/src/TMemoryRegulator.h
  • bindings/pyroot/pythonizations/src/TMemoryRegulator.cxx