Indirect leak in `Scheduler` class
Required prerequisites
-
Make sure you've read the documentation. Your issue may be addressed there. -
Search the issue tracker and discussions to verify that this hasn't already been reported. +1 or comment there if it has.
What commit version of aidge do you use
-
aidge_core
: 0.3.0
Problem description
In the context of solving memory leaks in Aidge aidge#195, a source of indirect leak in the form of a circular reference of shared_ptr
was found in the Scheduler class.
The Scheduler
uses a structure called the StaticSchedulingElement
storing a Node
and two lists of shared_ptr
to other StaticSchedulingElement
than should be run before (laterThan
) and after (earlierThan
) it. Sequential Nodes induce circular references between StaticSchedulingElement
.
Reproducible example code
Simply create a GraphView
with at least two nodes connected to each other and generate a scheduling for this graph. You just created an indirect leak.
Solution
These lists can be changed to lists of raw pointers as each StaticSchedulingElement
is globaly stored in the Scheduler::mStaticScheduler
attribute and should not outlive there storage in it. So clean deletion of StaticSchedulingElement
raw pointers can simply be handled.