-
Notifications
You must be signed in to change notification settings - Fork 427
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 Actions Using EventsExecutor
#2661
base: rolling
Are you sure you want to change the base?
Conversation
Signed-off-by: Mauro Passerino <[email protected]>
My fix is a workaround for something that might not be needed: In ROS2 actions, the user first sends a goal request and gets an accepted/rejected response. Then they must send another request to get the result with
To support this, the server must store the result until expiration timeout, giving time for the client to request the result. The result is not cleaned when the client requests the result, it is cleaned using a timer (default expiration is 10 seconds). We at iRobot think it may be better for the server to send the result directly to the client as soon as it's ready, avoiding the need for storage and cleanup. This could work by replacing the second client/service pair with a simple publish-subscribe model, where the server publishes the result as soon as it’s available:
What do you think?
Yes, that's a good improvement for my fix implem. |
Signed-off-by: Mauro Passerino <[email protected]>
Signed-off-by: Mauro Passerino <[email protected]>
Perhaps something worth bringing up in Client Library working group. CC: @alsora and @jmachowinski |
Why does this not happen ? |
To answer my own question, I just had a look at the code, and found the hidden timer in rcl, that we are missing in the events part. |
void | ||
ServerBase::initialize_expire_goal_timer() | ||
{ | ||
expire_goal_timer_ = rclcpp::create_wall_timer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a slight behavior difference to the rcl implementation here. RCL uses the clock of the node.
Perhaps use create_timer with the node clock ?
This pull request has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/next-client-library-wg-meeting-friday-8th-november-2024/40457/1 |
This pull request has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/next-client-library-wg-meeting-friday-8th-november-2024/40457/2 |
This pull request has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/next-client-library-wg-meeting-friday-22nd-november-2024/40703/1 |
When using ROS2 Actions with the
EventsExecutor
, completed goals are not automatically cleaned up becauseexecute_check_expired_goals()
is not called.As a result, goal results remain indefinitely stored, leading to increased memory usage with each completed goal.
In contrast, the
SingleThreadedExecutor
manages goal expiration using the server "goal expire" timeout onwait_for_work(<timeout>)
.To address this issue, I'm creating a one-shot timer on the server (only for
EventsExecutor
) that triggers after a goal expires, to handle cleanup.While other solutions may exist, this PR is primarily to discuss the issue and explore options.