Fix Ray Tune memory leak by clearing dangling ObjectRef#64236
Fix Ray Tune memory leak by clearing dangling ObjectRef#64236gmrnlg1971 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the set_ray_actor method in trial.py to set self._default_result_or_future to None when ray_actor is not provided. The reviewer suggests conditionally clearing this attribute only if it is a ray.ObjectRef to prevent discarding useful metadata when it has already been resolved to a dictionary.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| else: | ||
| self._default_result_or_future = None |
There was a problem hiding this comment.
If self._default_result_or_future has already been resolved to a dict (e.g., via last_result or _get_default_result_or_future), it is a plain Python dictionary and does not hold any Ray object references, so it cannot cause a Ray memory leak. Clearing it unconditionally discards useful metadata (like node_ip and pid of the trial) which might be needed for debugging or post-mortem analysis of the trial.
Consider only clearing self._default_result_or_future if it is indeed an instance of ray.ObjectRef.
| else: | |
| self._default_result_or_future = None | |
| else: | |
| if isinstance(self._default_result_or_future, ray.ObjectRef): | |
| self._default_result_or_future = None |
Signed-off-by: gmrnlg1971 <gmrnlg1971@users.noreply.github.com>
a20bb71 to
eca35b0
Compare
Description
Related issues
Additional information