Skip to content

cyclic dependency between broker and consumers #30

@Jonas-Wessner

Description

@Jonas-Wessner

The broker stores a vector of shared pointers to consumers.
The consumers store a shared pointer to the broker.
This cyclic shared pointer relationship creates a memory leak, because either object cannot be destructed when the shared pointer goes out of scope.
Proposed solution:
By using the GBROKER() macro instead of storing a member variable shared pointer to the broker in the consumers, we access temporary shared pointers that will be destroyed at the end of the respective statement, thereby not having any shared pointers to the brokers alive while the consumers are destructed. This breaks the cyclic dependency and resolves the problem

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions