Skip to content

Use init-on-first-use for global state#275

Merged
clalancette merged 2 commits intoros2:masterfrom
eboasson:gcdds-destruction
Jan 7, 2021
Merged

Use init-on-first-use for global state#275
clalancette merged 2 commits intoros2:masterfrom
eboasson:gcdds-destruction

Conversation

@eboasson
Copy link
Collaborator

@eboasson eboasson commented Jan 6, 2021

Otherwise global destructor ordering can result in the global state being
destroyed before the last use. Not cleaning up does cause a small memory leak
at shutdown, but it is limited to an empty map of domains and an empty
unordered set of waitsets.

Signed-off-by: Erik Boasson eb@ilities.com

Otherwise global destructor ordering can result in the global state being
destroyed before the last use.  Not cleaning up does cause a small memory leak
at shutdown, but it is limited to an empty map of domains and an empty
unordered set of waitsets.

Signed-off-by: Erik Boasson <eb@ilities.com>
Copy link
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.

The code looks OK to me. There's one style error inline I've pointed out.

I also think we should add a comment above the gcdds() function explaining why we are doing this and the tradeoff of never calling the destructor. That will help future readers understand.

Finally, a CI run with this in place, both with and without ros2/rmw#293, would be good to ensure that the problem there is solved.

Signed-off-by: Erik Boasson <eb@ilities.com>
Copy link
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.

Looks good to me. I'm going to go ahead and run full CI on this both for the current state of the world, and in combination with ros2/rmw#293 to make sure things are happy.

@clalancette
Copy link
Contributor

CI with just this PR in place:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status
  • Windows Debug Build Status

@clalancette
Copy link
Contributor

clalancette commented Jan 7, 2021

CI with this PR and ros2/rmw#293:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status
  • Windows Debug Build Status

@clalancette
Copy link
Contributor

All right, looking at the CI results with just this PR in place:

So as far as I can tell this PR is ready to go. I'm going to go ahead and merge, thanks @eboasson !

@clalancette clalancette merged commit a9e92d0 into ros2:master Jan 7, 2021
eboasson added a commit to eboasson/rmw_cyclonedds that referenced this pull request May 17, 2021
* Use init-on-first-use for global state

Otherwise global destructor ordering can result in the global state being
destroyed before the last use.  Not cleaning up does cause a small memory leak
at shutdown, but it is limited to an empty map of domains and an empty
unordered set of waitsets.

Signed-off-by: Erik Boasson <eb@ilities.com>
clalancette pushed a commit to eboasson/rmw_cyclonedds that referenced this pull request May 18, 2022
* Use init-on-first-use for global state

Otherwise global destructor ordering can result in the global state being
destroyed before the last use.  Not cleaning up does cause a small memory leak
at shutdown, but it is limited to an empty map of domains and an empty
unordered set of waitsets.

Signed-off-by: Erik Boasson <eb@ilities.com>
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