Memory pool for RooArgSet and RooDataSet.
RooArgSet and RooDataSet were using a mempool that guarantees that allocating, de-allocating and re-allocating a set does not yield the same pointer. Since both were using the same logic, the functionality has been put in this class. This class solves RooFit's static destruction order problems by intentionally leaking arenas of the mempool that still contain live objects at the end of the program.
When the set types are compared based on a unique ID instead of their pointer, one can go back to normal memory management, and this class becomes obsolete.
Definition at line 33 of file MemPoolForRooSets.h.
Classes | |
struct | Arena |
Public Member Functions | |
MemPoolForRooSets () | |
Create empty mem pool. More... | |
MemPoolForRooSets (const MemPoolForRooSets &)=delete | |
MemPoolForRooSets (MemPoolForRooSets &&)=delete | |
~MemPoolForRooSets () | |
Destructor. Should not be called when RooArgSets or RooDataSets are still alive. More... | |
void * | allocate (std::size_t bytes) |
Allocate memory for the templated set type. Fails if bytes != sizeof(RooSet_t). More... | |
bool | deallocate (void *ptr) |
Deallocate memory for the templated set type if in pool. More... | |
bool | empty () const |
Test if pool is empty. More... | |
MemPoolForRooSets & | operator= (const MemPoolForRooSets &)=delete |
MemPoolForRooSets & | operator= (MemPoolForRooSets &&)=delete |
void | prune () |
Free memory in arenas that don't have space and no users. More... | |
void | teardown () |
Set pool to teardown mode (at program end). More... | |
Private Member Functions | |
void | newArena () |
RooFit relies on unique pointers for RooArgSets. More... | |
Private Attributes | |
std::vector< Arena > | fArenas |
bool | fTeardownMode {false} |
|
inline |
Create empty mem pool.
Definition at line 179 of file MemPoolForRooSets.h.
|
delete |
|
delete |
|
inline |
Destructor. Should not be called when RooArgSets or RooDataSets are still alive.
Definition at line 187 of file MemPoolForRooSets.h.
|
inline |
Allocate memory for the templated set type. Fails if bytes != sizeof(RooSet_t).
Definition at line 200 of file MemPoolForRooSets.h.
|
inline |
Deallocate memory for the templated set type if in pool.
Definition at line 226 of file MemPoolForRooSets.h.
|
inline |
Test if pool is empty.
Definition at line 265 of file MemPoolForRooSets.h.
|
inlineprivate |
RooFit relies on unique pointers for RooArgSets.
Here, memory has to be allocated until a completely new chunk of memory is encountered. As soon as RooXXXSets can be identified with a unique ID, this becomes obsolete.
Definition at line 289 of file MemPoolForRooSets.h.
|
delete |
|
delete |
|
inline |
Free memory in arenas that don't have space and no users.
In fTeardownMode, it will also delete the arena that still has space.
Definition at line 249 of file MemPoolForRooSets.h.
|
inline |
Set pool to teardown mode (at program end).
Will prune all empty arenas. Non-empty arenas will survive until all contained elements are deleted. They may therefore leak if not all elements are destructed.
Definition at line 275 of file MemPoolForRooSets.h.
|
private |
Definition at line 306 of file MemPoolForRooSets.h.
|
private |
Definition at line 307 of file MemPoolForRooSets.h.