Skip to content

Use ThreadLocal.remove() rather than .set(null) #30

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

Merged
merged 1 commit into from
Aug 18, 2015

Conversation

spencergibb
Copy link
Member

fixes gh-27

/cc @rwinch

@rwinch
Copy link

rwinch commented Aug 18, 2015

Looks good to me :)

spencergibb added a commit that referenced this pull request Aug 18, 2015
Use ThreadLocal.remove() rather than .set(null)
@spencergibb spencergibb merged commit 44e4a2d into master Aug 18, 2015
@marcingrzejszczak marcingrzejszczak deleted the threadlocal-remove branch September 7, 2016 15:51
@cincat
Copy link

cincat commented Mar 15, 2021

@rwinch @spencergibb I think the memory leak is not caused by ThreadLocal.set(null), because theadLocalMap just hold the weak reference of ThreadLocal variable, the strong relationship held is by the thread itself.

@marcingrzejszczak
Copy link
Contributor

You're referring to the code that is 6 years old. There's no such code anymore!

@cincat
Copy link

cincat commented Mar 15, 2021

It's okay, I just wanna to confirm that ThreadLocal.set(null) cannot cause memory leaks.

@cincat
Copy link

cincat commented Mar 16, 2021

And I am certain that the code is never changed since 6 years ago.

@spencergibb
Copy link
Member Author

@cincat there's no such class TraceContextHolder anymore.

@spring-cloud spring-cloud locked as resolved and limited conversation to collaborators Mar 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use ThreadLocal.remove() to prevent memory leaks
4 participants