Skip to content

pass engine by pointer, reducing memory leak

Tommaso Lari requested to merge tlari/athena:sim7268 into main

It should address ATLASSIM-7268

The CLHEP::RandFlat class has both constructors with the engine passed by reference or by pointer. As noted by @sroe in the ticket, the comment in the code that the engine should be passed by reference to avoid CHEP taking ownership is not correct. The documentation comments on the difference :

If the engine is passed by pointer the corresponding engine object will be deleted by the RandFlat destructor. If the engine is passed by reference the corresponding engine object will not be deleted by the RandFlat destructor.

The RandFlat object and the engine are created in the initialize() method of BkgStreamsCache, and the destructor deletes the Randflat object. Hence I would say that passing the pointer by reference instead than by pointer causes a memory leak (the engine is not deleted) though it should be negligible since it's not in the event loop.

Merge request reports

Loading