Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On the way to fixing #1919 #1920

Draft
wants to merge 5 commits into
base: ros2
Choose a base branch
from
Draft

Conversation

ugol-1
Copy link

@ugol-1 ugol-1 commented Nov 2, 2023

No description provided.

@@ -110,7 +101,7 @@ class Plugin : public std::enable_shared_from_this<Plugin>
}

protected:
UASPtr uas; // uas back link
std::weak_ptr<UAS> uas_; // uas back link
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What for? Shared ptr good enough.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shared_ptr is not good here, because it creates cyclic references. The UAS node holds shared_ptrs to plugin nodes. In turn, each plugin node holds a shared_ptr to the UAS node. The result is that the UAS node and the plugin nodes never get destroyed.
You can check this by loading the mavros::uas::UAS component into a component container and then unloading it. The nodes will still be there. And then load it again, every node will get duplicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants