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

是否有内存泄露的风险? #96

Closed
candyleer opened this issue Jul 4, 2018 · 3 comments
Closed

是否有内存泄露的风险? #96

candyleer opened this issue Jul 4, 2018 · 3 comments
Assignees
Labels
❓question Further information is requested

Comments

@candyleer
Copy link

candyleer commented Jul 4, 2018

这种继承的Threadlocal,如果嵌入层次比较深,最后没有调用 remove() 方法,是否会引起内存泄露?

@oldratlee oldratlee added the ❓question Further information is requested label Jul 5, 2018
@oldratlee
Copy link
Member

oldratlee commented Jul 5, 2018

这种继承的 threadlocal 如果嵌入层次比较深,最后没有调用 remove() 方法

关于『嵌入层次比较深』,问题要分段分析,业务系统都是有非常多的组件,基于是每一段和系统的理解和使用:

  • 每一段的使用是OK的,
  • 且不同段的组合是OK的,
  • 那么整体系统会是OK的。

是否会引起内存泄露

关于TransmittableThreadLocal这一段的内存的问题:

在内存持有的问题上,TransmittableThreadLocalThreadLocal 是一样的,本身是没有问题的。
在业务使用上,了解/理解一下 ThreadLocal 使用上的注意。

具体的分析确定,你可以: @candyleer

  1. TransmittableThreadLocal 已经提供了 内存泄露的测试Case。你可以自己来直接运行验证一下
    PS: 测试Case中 没有 调用remove
    https://github.com/alibaba/transmittable-thread-local/blob/master/docs/performance-test.md#-%E5%86%85%E5%AD%98%E6%B3%84%E6%BC%8F
  2. 理解 ThreadLocalTransmittableThreadLocal 的使用方式、过程 和 内存持有的实现。

image

@candyleer
Copy link
Author

感谢回答

@oldratlee
Copy link
Member

好的 ❤️ Close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants