Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Avoid leaking DDS::Topic objects#444

Merged
ivanpauno merged 4 commits intomasterfrom
ivanpauno/avoid-leaking-dds-topics
Jul 27, 2020
Merged

Avoid leaking DDS::Topic objects#444
ivanpauno merged 4 commits intomasterfrom
ivanpauno/avoid-leaking-dds-topics

Conversation

@ivanpauno
Copy link
Copy Markdown
Member

Follow up of #442.

Based on find_topic documentation, it returns a object that can be independently destroyed and not a reference to the one found.

This PR modifies publisher/subscription creation and destruction, so that the DDS::Topic objects are destroyed as soon as possible (i.e. when destroying a publisher/subscription).

For example, an application that creates and destroy a publisher on the same topic repeatedly was increasingly allocating more resources. This PR avoids that.

I've also simplified topic creation code, as using both find_topic and lookup_topic_descritpion is redundant.

This passes rcl tests correctly locally, but it deserves full CI before being merged.


Publisher and Subscriptions are still leaking the "registered type", but that's much more complex to fix because we're using undocumented rti functions 😕.

Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
@ivanpauno ivanpauno added bug Something isn't working in review Waiting for review (Kanban column) labels Jul 24, 2020
@ivanpauno ivanpauno self-assigned this Jul 24, 2020
Copy link
Copy Markdown
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

Overall, this is a good find. It's a little unfortunate for performance that we are causing copies of the DDSTopic to be made for every caller that comes in here, but I think this is simpler than doing a reference count or anything like that.

I've got one big question and a few nits inline, otherwise looking good.

Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
@ivanpauno
Copy link
Copy Markdown
Member Author

It's a little unfortunate for performance that we are causing copies of the DDSTopic to be made for every caller that comes in here, but I think this is simpler than doing a reference count or anything like that

Based on rti documentation, it does seem like they are doing reference counting internally and that the copy should be cheap.

Copy link
Copy Markdown
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

Minor nit, but otherwise looks good to me with green CI. I'll suggest running test_communication with this change in place just to get a little broader test coverage.

Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>

Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
@ivanpauno
Copy link
Copy Markdown
Member Author

ivanpauno commented Jul 24, 2020

@ivanpauno ivanpauno merged commit e83bb12 into master Jul 27, 2020
@delete-merged-branch delete-merged-branch bot deleted the ivanpauno/avoid-leaking-dds-topics branch July 27, 2020 14:14
@hidmic hidmic mentioned this pull request Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working in review Waiting for review (Kanban column)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants