ThreadLocal & Memory Leak

前端 未结 7 1284
Happy的楠姐
Happy的楠姐 2020-11-27 10:08

It is mentioned at multiple posts: improper use of ThreadLocal causes Memory Leak. I am struggling to understand how Memory Leak would happen using Thread

7条回答
  •  爱一瞬间的悲伤
    2020-11-27 10:34

    The previous posts explain the problem but don't provide any solution. I found that there is no way to "clear" a ThreadLocal. In a container environment where I'm handling requests, I finally just called .remove() at the end of every request. I realize that could be problematic using container managed transactions.

提交回复
热议问题