Skip to content
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

Use Threadlocal.remove() instead of Threadlocal.set(null) #4601

Closed

Conversation

Seungpang
Copy link
Contributor

Hi Team,

This PR improves memory management by replacing instances of ThreadLocal.set(null) with ThreadLocal.remove() and removing the unnecessary ThreadLocal.set(null) in the constructor.

In the current implementation, ThreadLocal.set(null) is used to clear the ThreadLocal variable. This approach can leave the ThreadLocal variable in the thread's local variable map with a null value, potentially causing memory leaks. Using ThreadLocal.remove() instead properly removes the ThreadLocal variable from the thread's local variable map, preventing memory leaks.

Additionally, the constructor for JobFlowExecutor contains an unnecessary ThreadLocal.set(null), which is redundant because the ThreadLocal variable is already initialized to null by default.

@fmbenhassine
Copy link
Contributor

LGTM. Rebased and merged as 3b9ceea. Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants