launch
launch copied to clipboard
Actions (particularly ExecuteProcess) exist indefinitely
Bug report
Required Info:
- Operating System:
- Ubuntu 20.04
- Installation type:
- both
- Version or commit hash:
- foxy
- DDS implementation:
- fastrtps
- Client library (if applicable):
- launch
Steps to reproduce issue
I have created a wrapper around the LaunchService
which can dynamically add new Nodes and/or shutdown existing nodes.
New nodes are dynamically added by calling LaunchService.include_launch_description
during runtime.
Nodes are stopped by emitting a ShutdownProcess
event.
Expected behaviour
After ShutdownProcess
, the node exits and the Node/ExecuteProcess object is destroyed.
Actual behavior
I observed that the Node (ExecuteProcess) object is not destroyed until the LaunchService completely shutdown. This is also the case if the node exits on it's own (without a ShutdownProcess event).
Additional information
The result is a small memory leak. Which stacks up in my use case of long lived LaunchService.
I looked at LaunchService._prune_and_count_entity_future_pairs
where the Action is removed from entity_future_pairs
. The Action is indeed pruned. However there are still ~18 references to it in event handlers.
@joncppl thanks for reporting. I agree that ExecuteProcess
could do a better job at cleaning things up. Having said that, this is Python code. It may take a good while for gc
to kick in.
Would you be willing to contribute such an improvement?