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

Fix memory leak in the ros2_control #2033

Conversation

saikishor
Copy link
Member

For some reason, the get_name method that is returning by copy is creating various mallocs in the RT loop and this is causing slight memory leaks.

gdb with breakpoint on malloc, brings me to these logs, so it would be nice to have this sorted to not have allocations in the RT loop

#2  0x00007f71817f5cdd in ?? () from //lib/librobot_control.so
#3  0x00007f718580eb29 in hardware_interface::System::get_name[abi:cxx11]() const () from lib/libhardware_interface.so
#4  0x00007f71857ebc62 in ?? () from lib/libhardware_interface.so
#5  0x00007f71857edd20 in hardware_interface::ResourceManager::read(rclcpp::Time const&, rclcpp::Duration const&) () from lib/libhardware_interface.so
#6  0x00007f718608b5de in controller_manager::ControllerManager::read(rclcpp::Time const&, rclcpp::Duration const&) () from lib/libcontroller_manager.so
#7  0x000055dd43023c26 in ?? ()
#8  0x00007f7185c38253 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#9  0x00007f71859a7ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#10 0x00007f7185a39850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
```

Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.37%. Comparing base (2dc3725) to head (194e869).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2033      +/-   ##
==========================================
+ Coverage   89.33%   89.37%   +0.04%     
==========================================
  Files         138      138              
  Lines       14772    14762      -10     
  Branches     1270     1270              
==========================================
- Hits        13196    13193       -3     
+ Misses       1100     1092       -8     
- Partials      476      477       +1     
Flag Coverage Δ
unittests 89.37% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
..._interface/include/hardware_interface/actuator.hpp 100.00% <ø> (ø)
.../include/hardware_interface/actuator_interface.hpp 91.15% <100.00%> (-0.82%) ⬇️
...rface/include/hardware_interface/hardware_info.hpp 100.00% <100.00%> (ø)
...re_interface/include/hardware_interface/sensor.hpp 100.00% <ø> (ø)
...ce/include/hardware_interface/sensor_interface.hpp 90.90% <100.00%> (-4.48%) ⬇️
...re_interface/include/hardware_interface/system.hpp 100.00% <ø> (ø)
...ce/include/hardware_interface/system_interface.hpp 81.81% <100.00%> (ø)
hardware_interface/src/actuator.cpp 80.66% <100.00%> (ø)
hardware_interface/src/sensor.cpp 76.03% <100.00%> (ø)
hardware_interface/src/system.cpp 80.66% <100.00%> (ø)
... and 3 more

Copy link

@Juliaj Juliaj left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Member

@arne48 arne48 left a comment

Choose a reason for hiding this comment

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

LGTM

@bmagyar bmagyar merged commit 7406bdc into ros-controls:master Feb 7, 2025
23 of 26 checks passed
@bmagyar bmagyar deleted the fix/hardware_components/memory_leak branch February 7, 2025 09:45
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.

4 participants