Closed mslijepc closed 2 years ago
Or the memory management is the responsibility of find_or_create
?
Indeed this is a memory leak. The fsm handles are created at https://github.com/Arteris-IP/tlm2-interfaces/blob/48e2de7033275bfc1807925e96154d43325a7325/axi/fsm/base.cpp#L53. Once the bus transaction is finished they are returned into a pool of handles (https://github.com/Arteris-IP/tlm2-interfaces/blob/48e2de7033275bfc1807925e96154d43325a7325/axi/fsm/base.h#L165) and reused from there. But this pool is not free'd upon destruction thus in principle creating a memory leak. Since there is no dynamic instantiation of modules (and hence axi fsms) we did not see this critical yet.
One proposal to fix it:
base.h
std::vector<std::unique_ptr<axi::fsm::fsm_handle>> allocated_ptrs;
base.cpp (need slight modification of axi::fsm::fsm_handle
, since there is also potential memory leak)
auto* fsm_hndl = create_fsm_handle();
allocated_ptrs.emplace_back(fsm_hndl);
fsm_hndl->fsm = std::make_shared<AxiProtocolFsm>();
Hi,
I have run
asan
(but not on the original repo) and found possible memory leak in: https://github.com/Minres/SystemC-Components/blob/ad8aef0430a196df822740fa9984885553ce45f1/src/bus_interfaces/axi/pin/axi4_target.h#L250fsm_handle
object is created by callingfind_or_create
, but never deleted