Memory leak on rclpy subscriber
See original GitHub issueDuring the work, we noticed that memory consumption of our docker container(with ROS2 Foxy) has been increased with time. We did research and found that this memory is allocated for the node, written in python.
We tried to reproduce the issue with a simple application and we reproduced it on clean foxy docker with a demo application.
Bug report
Required Info:
- Operating System:
- Ubuntu 18.04(doesn’t matter in this case, as in docker other OS is used)
- Installation type:
- binaries
- Version or commit hash:
- Foxy
- DDS implementation:
- default
- Client library (if applicable):
- rclpy
Steps to reproduce issue
- Download docker file from the repository dockerfile
- Go to the folder where you’ve saved dockerfile in the previous step Build docker with a command like
docker build -t ros2-foxy .
- Run docker with the listener from demo py package
docker run -it --rm ros2-foxy ros2 run demo_nodes_py listener
- Run rqt tool on your environment or in the other docker
- Check if /chatter topic is available. It should be created by the listener node
- In rqt, configure message publisher to send messages to the chatter with high frequency, e.g. 5000Hz. The frequency doesn’t matter, but with such frequency, we will see issue sooner
- Check docker(where the listener is run) memory consumption. In my case it was ~60Mb
- Wait for some time, in my case about 30 min
Expected behavior
Memory consumption is on the same level
Actual behavior
Memory consumption is increased to 330mB
Additional information
Memory consumption is not decreased when we stop message publishing.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
ROS2 serious memory leak when using timer? - ROS Answers
Trying memory profiler (mprof) shows that in 4 min, memory consumption is increased by at least 10MB. import sys import rclpy import time ......
Read more >Google Cloud PubSub python subscriber leaks memory
It looks like the subscriber is leaking memory and the amount of memory leaked is directly proportional to the underlying callback memory usage ......
Read more >Topics — rclpy 0.6.1 documentation - ROS 2 Docs
topic ( str ) – The name of the topic the subscription will subscribe to. callback ( Callable ) – A user-defined callback...
Read more >Preventing Angular Subscription Memory Leaks | Jake Cyr
In my early Angular days, I would subscribe to observables without unsubscribing before the app was destroyed, possibly leading to a build up...
Read more >Debug a memory leak in .NET Core - Microsoft Learn
This tutorial demonstrates the tools to analyze a memory leak in a . ... Here you can see that most objects are either...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@fujitatomoya
with _WaitSet() to call
__enter__
and__exit__
, it seems there is no memory leak. https://github.com/ros2/rclpy/blob/d7b4688743a99063e444f216f30c462fb03369b3/rclpy/rclpy/executors.py#L63-L71Maybe it’s related to
Yes, as the issue has been addressed we can close it