Skip to content

use weak_ptr for rcl entities in the memory strategy.#2988

Merged
fujitatomoya merged 1 commit intorollingfrom
fujitatomoya/use-weakptr-memory-strategy
Feb 1, 2026
Merged

use weak_ptr for rcl entities in the memory strategy.#2988
fujitatomoya merged 1 commit intorollingfrom
fujitatomoya/use-weakptr-memory-strategy

Conversation

@fujitatomoya
Copy link
Collaborator

Description

i would like to discuss on this enhancement.

we should not keep the shared pointer to rcl entity handles inside the MemoryStrategy?
instead, we could use weak / non-owning references in the following vectors?
this avoids extending the lifetime of the underlying rcl entity beyond the node that owns it, while still allowing the memory strategy to observe live handles.

as you can see the test, this actually cleans up the destruction sequence.

Is this user-facing behavior change?

Did you use Generative AI?

No,

Additional Information

No,

@fujitatomoya fujitatomoya self-assigned this Nov 17, 2025
@fujitatomoya fujitatomoya added the enhancement New feature or request label Nov 17, 2025
Copy link
Collaborator Author

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

@jmachowinski @skyegalaxy @wjwwood can you take a look at this when you have time?

Copy link
Member

@skyegalaxy skyegalaxy left a comment

Choose a reason for hiding this comment

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

lgtm, this definitely seems cleaner

@fujitatomoya
Copy link
Collaborator Author

fujitatomoya commented Nov 18, 2025

Pulls: #2988
Gist: https://gist.githubusercontent.com/fujitatomoya/f3e38b945fe546b56afd8f7196c83352/raw/f97278a9cd02cac7983b3c887023bfb3813d5dd0/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp
TEST args: --packages-above rclcpp
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/17516

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@jmachowinski
Copy link
Collaborator

jmachowinski commented Nov 18, 2025

This is dead code, and can be removed altogether.
This was a big part of the old executor implementation before the double buffering changes introduced shortly before jazzy. As far as I can see it it not used any more.

@fujitatomoya
Copy link
Collaborator Author

@skyegalaxy thanks for review.

@jmachowinski ah i did not remember that, thanks for point that out. i was checking the flaky result of test_allocator_memory_strategy.cpp, and trying to fix the problems.

probably what we should do is that deprecate those methods and classes, and remove the corresponding test cases.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
@fujitatomoya fujitatomoya reopened this Jan 28, 2026
@fujitatomoya fujitatomoya force-pushed the fujitatomoya/use-weakptr-memory-strategy branch from c605630 to 11e6ce2 Compare January 28, 2026 06:54
@fujitatomoya
Copy link
Collaborator Author

@skyegalaxy thanks for review.

@jmachowinski ah i did not remember that, thanks for point that out. i was checking the flaky result of test_allocator_memory_strategy.cpp, and trying to fix the problems.

probably what we should do is that deprecate those methods and classes, and remove the corresponding test cases.

i reopend this pr because,

  • since those are public APIs (not used in rclcpp anymore), we should 1st fix the problem to keep the CI stability and user application support.
  • we deprecate the AllocatorMemoryStrategy and related methods and classes all together with deprecation period.
  • after lyrical luth, we can remove the deprecated classes and methods with all test cases together.

i believe this is what needs to be done by procedure.

CC: @jmachowinski @skyegalaxy

@fujitatomoya
Copy link
Collaborator Author

Pulls: #2988
Gist: https://gist.githubusercontent.com/fujitatomoya/af18081bb0cced9c763ef723a95f8437/raw/8dd846b6dfd0c8bb0bda5dd26a8e4905e6fd972f/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp
TEST args: --packages-above rclcpp
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18054

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@jmachowinski
Copy link
Collaborator

@fujitatomoya Should we add a deprecation now together with this PR ?

@fujitatomoya
Copy link
Collaborator Author

@jmachowinski once we deprecate those unused classes, there were many places need to be removed to make the CI green. so i would say we can do that with another PR?

@fujitatomoya
Copy link
Collaborator Author

fujitatomoya commented Jan 29, 2026

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@fujitatomoya fujitatomoya merged commit c7065f7 into rolling Feb 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants