launch icon indicating copy to clipboard operation
launch copied to clipboard

Actions (particularly ExecuteProcess) exist indefinitely

Open joncppl opened this issue 3 years ago • 1 comments

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 avatar Dec 01 '21 23:12 joncppl

@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?

hidmic avatar Dec 07 '21 17:12 hidmic