Memory grows per callback group created and destroyed on long lived nodes

Offen
#3,428 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@jwallace42 arbeitet bereits daran.

Seit 25.11.2026.

  • #3437 von @jwallace42 — offen

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
28/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
cpp
Bereich
performance

Rechercherichtung

The body names no file: start from rclcpp/src/rclcpp/node_interfaces/node_base.cpp, which stores the node's callback groups, and rclcpp/src/rclcpp/executor.cpp, which collects them and holds references. Reproduce by creating and destroying callback groups in a loop on a long-lived node while watching RSS (the reporter's rclcpp_cbg_leak_test package is the model). Done looks like flat memory across iterations plus a regression test under rclcpp/test/rclcpp/.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug
Generated by Generative AI

No

Operating System:

Linux josh-MS-A2 7.0.0-43-generic #43~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 31 06:52:47 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

ROS version or commit hash:

Rolling

RMW implementation (if applicable):

Not applicable

RMW Configuration (if applicable):

Not applicable

Client library (if applicable):

rclcpp:

'ros2 doctor --report' output
ros2 doctor --report
  ACTION LIST
action                 : none
action server count    : 0
action client count    : 0

   ROS ENVIRONMENT
ROS environment variables        : ROS_AUTOMATIC_DISCOVERY_RANGE=SUBNET, ROS_DISTRO=rolling
rcutils environment variables    : 
rmw environment variables        : 

   NETWORK CONFIGURATION
inet         : 127.0.0.1
inet4        : ['127.0.0.1']
inet6        : ['::1']
netmask      : 255.0.0.0
device       : lo
flags        : UP,LOOPBACK,RUNNING
mtu          : 65536
inet         : 172.17.0.2
inet4        : ['172.17.0.2']
ether        : 66:77:a8:6b:92:e6
netmask      : 255.255.0.0
device       : eth0
flags        : UP,BROADCAST,RUNNING,MULTICAST
mtu          : 1500
broadcast    : 172.17.255.255

   PACKAGE VERSIONS
rclcpp_cbg_leak_test                      : latest=N/A, local=0.1.0
nav2_bringup                              : latest=N/A, local=1.5.0
navigation2                               : latest=N/A, local=1.5.0
opennav_following                         : latest=N/A, local=1.5.0
opennav_docking                           : latest=N/A, local=1.5.0
opennav_docking_core                      : latest=N/A, local=1.5.0
opennav_docking_bt                        : latest=N/A, local=1.5.0
nav2_dwb_controller                       : latest=N/A, local=1.5.0
dwb_plugins                               : latest=N/A, local=1.5.0
dwb_critics                               : latest=N/A, local=1.5.0
dwb_core                                  : latest=N/A, local=1.5.0
nav_2d_utils                              : latest=N/A, local=1.5.0
dwb_msgs                                  : latest=N/A, local=1.5.0
nav_2d_msgs                               : latest=N/A, local=1.5.0
nav2_waypoint_follower                    : latest=N/A, local=1.5.0
nav2_theta_star_planner                   : latest=N/A, local=1.5.0
nav2_smoother                             : latest=N/A, local=1.5.0
nav2_smac_planner                         : latest=N/A, local=1.5.0
nav2_rviz_plugins                         : latest=N/A, local=1.5.0
nav2_route                                : latest=N/A, local=1.5.0
nav2_rotation_shim_controller             : latest=N/A, local=1.5.0
nav2_regulated_pure_pursuit_controller    : latest=N/A, local=1.5.0
nav2_planner                              : latest=N/A, local=1.5.0
nav2_navfn_planner                        : latest=N/A, local=1.5.0
nav2_mppi_controller                      : latest=N/A, local=1.5.0
nav2_graceful_controller                  : latest=N/A, local=1.5.0
nav2_controller                           : latest=N/A, local=1.5.0
nav2_constrained_smoother                 : latest=N/A, local=1.5.0
nav2_bt_navigator                         : latest=N/A, local=1.5.0
nav2_behaviors                            : latest=N/A, local=1.5.0
nav2_core                                 : latest=N/A, local=1.5.0
nav2_collision_monitor                    : latest=N/A, local=1.5.0
costmap_queue                             : latest=N/A, local=1.5.0
nav2_costmap_2d                           : latest=N/A, local=1.5.0
nav2_voxel_grid                           : latest=N/A, local=1.5.0
nav2_velocity_smoother                    : latest=N/A, local=1.5.0
nav2_map_server                           : latest=N/A, local=1.5.0
nav2_loopback_sim                         : latest=N/A, local=1.5.0
nav2_lifecycle_manager                    : latest=N/A, local=1.5.0
nav2_behavior_tree                        : latest=N/A, local=1.5.0
nav2_amcl                                 : latest=N/A, local=1.5.0
nav2_util                                 : latest=N/A, local=1.5.0
nav2_system_tests                         : latest=N/A, local=1.5.0
nav2_simple_commander                     : latest=N/A, local=1.5.0
nav2_ros_common                           : latest=N/A, local=1.5.0
nav2_msgs                                 : latest=N/A, local=1.5.0
nav2_common                               : latest=N/A, local=1.5.0
shape_msgs                                : latest=5.10.3, local=5.10.3
rosidl_adapter                            : latest=5.3.2, local=5.3.2
rmw_dds_common                            : latest=6.1.3, local=6.1.3
rosidl_buffer                             : latest=5.3.2, local=5.3.2
rosidl_typesupport_fastrtps_cpp           : latest=3.10.2, local=3.10.2
rosgraph_msgs                             : latest=2.5.2, local=2.5.2
ros2run                                   : latest=0.42.2, local=0.42.2
ament_package                             : latest=0.19.1, local=0.19.1
rcl_logging_implementation                : latest=3.5.1, local=3.5.1
ros_workspace                             : latest=1.0.3, local=1.0.3
tracetools                                : latest=9.0.0, local=9.0.0
pluginlib                                 : latest=6.0.3, local=6.0.3
ament_cmake_target_dependencies           : latest=2.9.3, local=2.9.3
launch_testing_ament_cmake                : latest=3.10.3, local=3.10.3
ament_cmake_include_directories           : latest=2.9.3, local=2.9.3
lifecycle_msgs                            : latest=2.5.2, local=2.5.2
ros_core                                  : latest=0.13.0, local=0.13.0
ament_cmake_test                          : latest=2.9.3, local=2.9.3
rosidl_typesupport_introspection_c        : latest=5.3.2, local=5.3.2
libyaml_vendor                            : latest=1.9.0, local=1.9.0
ament_mypy                                : latest=0.21.4, local=0.21.4
launch_ros                                : latest=0.30.3, local=0.30.3
rmw_implementation                        : latest=3.2.2, local=3.2.2
ros2log                                   : latest=0.42.2, local=0.42.2
ros2interface                             : latest=0.42.2, local=0.42.2
rmw_test_fixture                          : latest=0.16.1, local=0.16.1
ros2node                                  : latest=0.42.2, local=0.42.2
ament_flake8                              : latest=0.21.4, local=0.21.4
unique_identifier_msgs                    : latest=2.9.1, local=2.9.1
rosidl_buffer_backend_registry            : latest=5.3.2, local=5.3.2
ament_cmake_flake8                        : latest=0.21.4, local=0.21.4
ament_cmake_ros                           : latest=0.16.1, local=0.16.1
sros2_cmake                               : latest=0.17.1, local=0.17.1
std_msgs                                  : latest=5.10.3, local=5.10.3
ament_cpplint                             : latest=0.21.4, local=0.21.4
ros2launch                                : latest=0.30.3, local=0.30.3
rcl_action                                : latest=10.6.0, local=10.6.0
sensor_msgs                               : latest=5.10.3, local=5.10.3
ament_cmake_ros_core                      : latest=0.16.1, local=0.16.1
rosidl_default_generators                 : latest=1.9.0, local=1.9.0
type_description_interfaces               : latest=2.5.2, local=2.5.2
rosidl_dynamic_typesupport                : latest=0.5.1, local=0.5.1
ament_lint_auto                           : latest=0.21.4, local=0.21.4
visualization_msgs                        : latest=5.10.3, local=5.10.3
ament_cmake                               : latest=2.9.3, local=2.9.3
composition_interfaces                    : latest=2.5.2, local=2.5.2
uncrustify_vendor                         : latest=3.3.0, local=3.3.0
rosidl_typesupport_cpp                    : latest=3.5.1, local=3.5.1
rosidl_runtime_cpp                        : latest=5.3.2, local=5.3.2
rclcpp_action                             : latest=33.2.0, local=33.2.0
launch                                    : latest=3.10.3, local=3.10.3
ament_xmllint                             : latest=0.21.4, local=0.21.4
rcl_logging_spdlog                        : latest=3.5.1, local=3.5.1
ament_cppcheck                            : latest=0.21.4, local=0.21.4
rmw_fastrtps_cpp                          : latest=9.6.1, local=9.6.1
rcl_interfaces                            : latest=2.5.2, local=2.5.2
rcpputils                                 : latest=2.15.4, local=2.15.4
rosidl_core_runtime                       : latest=0.5.0, local=0.5.0
ament_cmake_export_libraries              : latest=2.9.3, local=2.9.3
ament_cmake_gtest                         : latest=2.9.3, local=2.9.3
rcl_logging_interface                     : latest=3.5.1, local=3.5.1
trajectory_msgs                           : latest=5.10.3, local=5.10.3
ros2action                                : latest=0.42.2, local=0.42.2
rosidl_typesupport_interface              : latest=5.3.2, local=5.3.2
ament_cmake_export_definitions            : latest=2.9.3, local=2.9.3
ament_cmake_libraries                     : latest=2.9.3, local=2.9.3
rosidl_typesupport_introspection_cpp      : latest=5.3.2, local=5.3.2
libstatistics_collector                   : latest=3.0.0, local=3.0.0
statistics_msgs                           : latest=2.5.2, local=2.5.2
ros2cli                                   : latest=0.42.2, local=0.42.0
rosidl_generator_rs                       : latest=0.5.0, local=0.5.0
ament_lint_cmake                          : latest=0.21.4, local=0.21.4
ros2service                               : latest=0.42.2, local=0.42.2
launch_testing_ros                        : latest=0.30.3, local=0.30.3
rclpy                                     : latest=11.0.4, local=11.0.4
ament_cmake_export_targets                : latest=2.9.3, local=2.9.3
ament_cmake_cpplint                       : latest=0.21.4, local=0.21.4
ament_cmake_export_include_directories    : latest=2.9.3, local=2.9.3
ros_environment                           : latest=5.0.0, local=5.0.0
ros2plugin                                : latest=6.0.3, local=6.0.3
rosidl_generator_type_description         : latest=5.3.2, local=5.3.2
rcl_lifecycle                             : latest=10.6.0, local=10.6.0
rosidl_default_runtime                    : latest=1.9.0, local=1.9.0
ament_cmake_core                          : latest=2.9.3, local=2.9.3
ros2multicast                             : latest=0.42.2, local=0.42.2
ros2doctor                                : latest=0.42.2, local=0.42.2
rosidl_parser                             : latest=5.3.2, local=5.3.2
rosidl_generator_c                        : latest=5.3.2, local=5.3.2
ros2param                                 : latest=0.42.2, local=0.42.2
ament_cmake_uncrustify                    : latest=0.21.4, local=0.21.4
rosidl_cli                                : latest=5.3.2, local=5.3.2
ament_cmake_pep257                        : latest=0.21.4, local=0.21.4
rosidl_typesupport_c                      : latest=3.5.1, local=3.5.1
ros2component                             : latest=0.42.2, local=0.42.2
common_interfaces                         : latest=5.10.3, local=5.10.3
ros2lifecycle                             : latest=0.42.2, local=0.42.2
ament_lint_common                         : latest=0.21.4, local=0.21.4
ament_cmake_xmllint                       : latest=0.21.4, local=0.21.4
rmw                                       : latest=7.11.3, local=7.11.3
ros2pkg                                   : latest=0.42.2, local=0.42.2
ament_cmake_auto                          : latest=2.9.3, local=2.9.3
rcl                                       : latest=10.6.0, local=10.6.0
ament_cmake_gmock                         : latest=2.9.3, local=2.9.3
ament_cmake_version                       : latest=2.9.3, local=2.9.3
ament_cmake_mypy                          : latest=0.21.4, local=0.21.4
ament_index_python                        : latest=1.14.2, local=1.14.2
rmw_security_common                       : latest=7.11.3, local=7.11.3
rosidl_buffer_py                          : latest=5.3.2, local=5.3.2
ament_copyright                           : latest=0.21.4, local=0.21.4
rmw_implementation_cmake                  : latest=7.11.3, local=7.11.3
ament_uncrustify                          : latest=0.21.4, local=0.21.4
rosidl_typesupport_fastrtps_c             : latest=3.10.2, local=3.10.2
rclcpp                                    : latest=33.2.0, local=33.2.0
rosidl_runtime_py                         : latest=0.16.1, local=0.16.1
diagnostic_msgs                           : latest=5.10.3, local=5.10.3
ros2topic                                 : latest=0.42.2, local=0.42.2
ros2cli_common_extensions                 : latest=0.6.1, local=0.6.1
rosidl_cmake                              : latest=5.3.2, local=5.3.2
rosidl_dynamic_typesupport_fastrtps       : latest=0.6.1, local=0.6.1
builtin_interfaces                        : latest=2.5.2, local=2.5.2
ament_cmake_copyright                     : latest=0.21.4, local=0.21.4
launch_testing                            : latest=3.10.3, local=3.10.3
ament_index_cpp                           : latest=1.14.2, local=1.14.2
rcutils                                   : latest=7.2.3, local=7.2.3
rcl_yaml_param_parser                     : latest=10.6.0, local=10.6.0
rosidl_generator_py                       : latest=0.28.1, local=0.28.1
rosidl_buffer_backend                     : latest=5.3.2, local=5.3.2
rpyutils                                  : latest=0.8.0, local=0.8.0
rclcpp_components                         : latest=33.2.0, local=33.2.0
sros2                                     : latest=0.17.1, local=0.17.1
ament_cmake_export_dependencies           : latest=2.9.3, local=2.9.3
rosidl_generator_cpp                      : latest=5.3.2, local=5.3.2
rosidl_pycommon                           : latest=5.3.2, local=5.3.2
ament_cmake_cppcheck                      : latest=0.21.4, local=0.21.4
rmw_test_fixture_implementation           : latest=0.16.1, local=0.16.1
ament_cmake_export_link_flags             : latest=2.9.3, local=2.9.3
ament_cmake_python                        : latest=2.9.3, local=2.9.3
ament_pep257                              : latest=0.21.4, local=0.21.4
rmw_fastrtps_shared_cpp                   : latest=N/A, local=9.6.0
std_srvs                                  : latest=5.10.3, local=5.10.3
action_msgs                               : latest=2.5.2, local=2.5.2
class_loader                              : latest=3.0.3, local=3.0.3
stereo_msgs                               : latest=5.10.3, local=5.10.3
console_bridge_vendor                     : latest=1.10.0, local=1.10.0
nav_msgs                                  : latest=5.10.3, local=5.10.3
launch_xml                                : latest=3.10.3, local=3.10.3
ament_lint                                : latest=0.21.4, local=0.21.4
ament_cmake_pytest                        : latest=2.9.3, local=2.9.3
launch_yaml                               : latest=3.10.3, local=3.10.3
geometry_msgs                             : latest=5.10.3, local=5.10.3
rosidl_core_generators                    : latest=0.5.0, local=0.5.0
ament_cmake_gen_version_h                 : latest=2.9.3, local=2.9.3
spdlog_vendor                             : latest=1.9.0, local=1.9.0
rclcpp_lifecycle                          : latest=33.2.0, local=33.2.0
rosidl_runtime_c                          : latest=5.3.2, local=5.3.2
service_msgs                              : latest=2.5.2, local=2.5.2
ament_cmake_lint_cmake                    : latest=0.21.4, local=0.21.4
kdl_parser                                : latest=3.1.0, local=3.1.0
generate_parameter_library                : latest=1.4.0, local=1.3.1
geographic_msgs                           : latest=1.0.7, local=1.0.7
gz_plugin_vendor                          : latest=0.4.2, local=0.4.2
ompl                                      : latest=2.0.2, local=2.0.2
hardware_interface                        : latest=6.13.0, local=6.13.0
diff_drive_controller                     : latest=6.10.1, local=6.10.1
ros_gz_interfaces                         : latest=4.0.3, local=4.0.3
zstd_point_cloud_transport                : latest=7.0.0, local=7.0.0
realtime_tools                            : latest=5.6.0, local=5.5.1
gz_dartsim_vendor                         : latest=0.1.3, local=0.1.3
gz_gui_vendor                             : latest=0.4.2, local=0.4.2
nav2_minimal_tb4_description              : latest=1.3.0, local=1.3.0
nav2_minimal_tb4_sim                      : latest=1.3.0, local=1.3.0
gz_tools_vendor                           : latest=0.3.2, local=0.3.2
gz_msgs_vendor                            : latest=0.4.3, local=0.4.3
gps_msgs                                  : latest=3.1.1, local=3.1.1
ros_gz_sim                                : latest=4.0.3, local=4.0.3
control_msgs                              : latest=6.11.0, local=6.11.0
controller_interface                      : latest=6.13.0, local=6.13.0
gz_ogre_next_vendor                       : latest=0.2.1, local=0.2.1
ament_cmake_google_benchmark              : latest=2.9.3, local=2.9.3
xacro                                     : latest=2.1.1, local=2.1.1
filters                                   : latest=2.2.2, local=2.2.2
sdformat_urdf                             : latest=3.0.0, local=3.0.0
cv_bridge                                 : latest=4.1.0, local=4.1.0
ros_gz_image                              : latest=4.0.3, local=4.0.3
gz_transport_vendor                       : latest=0.4.3, local=0.4.3
robot_localization                        : latest=4.0.0, local=4.0.0
point_cloud_interfaces                    : latest=7.0.0, local=7.0.0
robot_state_publisher                     : latest=3.6.3, local=3.6.3
vision_msgs                               : latest=4.3.0, local=4.2.0
generate_parameter_library_py             : latest=1.4.0, local=1.3.1
gz_sensors_vendor                         : latest=0.4.3, local=0.4.3
angles                                    : latest=1.16.1, local=1.16.1
tf2_sensor_msgs                           : latest=0.46.5, local=0.46.5
draco_point_cloud_transport               : latest=7.0.0, local=7.0.0
simulation_interfaces                     : latest=2.1.0, local=2.1.0
sdformat_vendor                           : latest=0.4.3, local=0.4.3
pal_statistics                            : latest=2.8.2, local=2.8.2
joint_state_publisher                     : latest=2.4.3, local=2.4.3
test_msgs                                 : latest=2.5.2, local=2.5.2
nav2_minimal_tb3_sim                      : latest=1.3.0, local=1.3.0
tf2_eigen                                 : latest=0.46.5, local=0.46.5
gz_fuel_tools_vendor                      : latest=0.4.2, local=0.4.2
actuator_msgs                             : latest=0.0.1, local=0.0.1
control_toolbox                           : latest=6.5.0, local=6.5.0
ros_gz_bridge                             : latest=4.0.3, local=4.0.3
point_cloud_transport_plugins             : latest=7.0.0, local=7.0.0
pal_statistics_msgs                       : latest=2.8.2, local=2.8.2
gz_physics_vendor                         : latest=0.5.4, local=0.5.4
zenoh_cpp_vendor                          : latest=0.14.1, local=0.14.1
joint_limits                              : latest=6.13.0, local=6.13.0
joint_state_broadcaster                   : latest=6.10.1, local=6.10.1
gz_common_vendor                          : latest=0.4.4, local=0.4.4
zstd_cmake_module                         : latest=0.35.0, local=0.35.0
bond                                      : latest=4.4.1, local=4.4.1
bondcpp                                   : latest=4.4.1, local=4.4.1
gz_rendering_vendor                       : latest=0.5.3, local=0.5.3
tcb_span                                  : latest=2.0.3, local=2.0.3
smclib                                    : latest=4.4.1, local=4.4.1
gz_sim_vendor                             : latest=0.5.5, local=0.5.5
behaviortree_cpp                          : latest=4.11.1, local=4.11.1
diagnostic_updater                        : latest=4.5.7, local=4.5.7
zlib_point_cloud_transport                : latest=7.0.0, local=7.0.0
marine_acoustic_msgs                      : latest=2.1.0, local=2.1.0
resource_retriever_service_plugin         : latest=1.0.3, local=1.0.3
yaml_cpp_vendor                           : latest=9.3.0, local=9.3.0
gz_utils_vendor                           : latest=0.5.2, local=0.5.2
message_filters                           : latest=8.0.5, local=8.0.5
gz_cmake_vendor                           : latest=0.5.3, local=0.5.3
laser_geometry                            : latest=3.0.2, local=3.0.2
tf2_geometry_msgs                         : latest=0.46.5, local=0.46.5
sensor_msgs_py                            : latest=5.10.3, local=5.10.3
rviz_rendering                            : latest=16.0.4, local=16.0.4
urdf_parser_plugin                        : latest=2.14.1, local=2.14.1
gz_math_vendor                            : latest=0.5.3, local=0.5.3
rviz2                                     : latest=16.0.4, local=16.0.4
tf2                                       : latest=0.46.5, local=0.46.5
tf2_ros                                   : latest=0.46.5, local=0.46.5
rviz_default_plugins                      : latest=16.0.4, local=16.0.4
image_transport                           : latest=7.0.5, local=7.0.5
rviz_ogre_vendor                          : latest=16.0.4, local=16.0.4
eigen3_cmake_module                       : latest=0.6.0, local=0.6.0
point_cloud_transport                     : latest=6.0.5, local=6.0.5
resource_retriever_interfaces             : latest=1.0.3, local=1.0.3
interactive_markers                       : latest=2.9.3, local=2.9.3
tf2_msgs                                  : latest=0.46.5, local=0.46.5
resource_retriever                        : latest=3.10.2, local=3.10.2
tf2_ros_py                                : latest=0.46.5, local=0.46.5
rviz_common                               : latest=16.0.4, local=16.0.4
urdf                                      : latest=2.14.1, local=2.14.1
map_msgs                                  : latest=2.6.1, local=2.6.1
tf2_py                                    : latest=0.46.5, local=0.46.5

   PLATFORM INFORMATION
system           : Linux
platform info    : Linux-7.0.0-43-generic-x86_64-with-glibc2.43
release          : 7.0.0-43-generic
processor        : 

   QOS COMPATIBILITY LIST
compatibility status    : No publisher/subscriber pairs found

   RMW MIDDLEWARE
middleware name    : rmw_fastrtps_cpp

   ROS 2 INFORMATION
distribution name      : rolling
distribution type      : ros2
distribution status    : rolling
release platforms      : {'debian': ['trixie'], 'fedora': ['44'], 'rhel': ['10'], 'ubuntu': ['resolute']}

   SERVICE LIST
service          : none
service count    : 0
client count     : 0

   TOPIC LIST
topic               : none
publisher count     : 0
subscriber count    : 0

================================================================================
                                !!! WARNING !!!                                 
================================================================================
The report includes all ROS 2 endpoint information and system platform information.
Please review the report before sharing, as it may contain sensitive or private data.
================================================================================

Steps to reproduce issue

The script below creates and drops a callback group over and over again.

The baseline mode runs the test with no callback group creation.
The test mode runs the test with callback group creation.

#include <cstdlib>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>

#include "rclcpp/rclcpp.hpp"

namespace
{

long rss_kb()
{
  std::ifstream f("/proc/self/status");
  std::string line;
  while (std::getline(f, line)) {
    if (line.rfind("VmRSS:", 0) == 0) {
      return std::stol(line.substr(6));
    }
  }
  return -1;
}

void usage(const char * prog)
{
  std::cerr << "usage: " << prog << " <baseline|test> [iters=30000] [warmup=2000]\n";
}

}

int main(int argc, char ** argv)
{
  rclcpp::init(argc, argv);
  if (argc < 2) {
    usage(argv[0]);
    return 2;
  }
  const std::string mode = argv[1];
  const int iters = argc > 2 ? std::atoi(argv[2]) : 30000;
  const int warm = argc > 3 ? std::atoi(argv[3]) : 2000;
  if (mode != "baseline" && mode != "test") {
    usage(argv[0]);
    return 2;
  }

  auto node = std::make_shared<rclcpp::Node>("cbg_test");

  auto step = [&]() {
      if (mode == "test") {
        auto group = node->create_callback_group(
      rclcpp::CallbackGroupType::MutuallyExclusive, false);
      }
    };

  for (int i = 0; i < warm; ++i) {
    step();
  }

  const long start = rss_kb();
  std::cout << "mode=" << mode << " warmup=" << warm << " start_rss_kb=" << start << std::endl;

  for (int i = 1; i <= iters; ++i) {
    step();
  }

  const long end = rss_kb();
  std::cout << "RESULT mode=" << mode << " iters=" << iters << " growth_kb=" << (end - start)
            << " bytes_per_iter=" << (1024.0 * (end - start) / iters) << std::endl;

  rclcpp::shutdown();
  return 0;
}
Expected behavior

The memory footprint should not grow.

Actual behavior

The growth is around 304 bytes per iteration.

Additional information

In node_base.cpp the create_callback_group builds the group and then adds it to a vector called calback_groups. This vector holds CallbackGroup::WeakPtr. Nothing ever removes from this group. It appears that enties of similar lifecyles pune when updates are made to the container. Is there a way we can add callback group to do something similar?

FYI @SteveMacenski

Vorherrschende Sprache
C++
Sterne
829
Forks
587
Ø Merge
4 T. 6 Std.
Gemergte PRs (30 T.)
30

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus ros2/rclcpp

Alle Issues in ros2/rclcpp

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.