Why does threadlocalmap cause memory leak?

Memory leak is caused when ThreadLocal is always existing. If ThreadLocal object could be GC, it will not cause memory leak. Because the entry in ThreadLocalMap extends WeakReference, the entry will be GC after ThreadLocal object is GC.

What is wrong with thread locals?

There is nothing inherently wrong with thread locals: They do not cause memory leaks. They are not slow. They are more local than their non-thread-local counterparts (i.e., they have better information hiding properties). They can be misused, of course, but so can most other programming tools…

How long are ThreadLocal values kept in a thread?

By definition, a reference to a ThreadLocal value is kept until the “owning” thread dies or if the ThreadLocal itself is no longer reachable.

What is the use of thread local in a web application?

A deployed web application uses a static ThreadLocal in one of its classes in order to store some thread-local data, an instance of another class (lets call it SomeClass) of the web application. This is done within the worker thread (e.g. this action originates from a HTTP request ).

How do I find a memory leak in a Confluence Project?

The atlassian-confluence.log will contain an error message like: Configure Java to produce a heap dump when it throws an OutOfMemoryError. Heap dumps can be used to determine what was in memory, and thereby find memory leaks and determine what parts of the system are using too much memory.

What is heap dump in confluence?

Heap dumps can be used to determine what was in memory, and thereby find memory leaks and determine what parts of the system are using too much memory. To generate a heap dump once an out of memory error occurs, add the following arguments to your Confluence as per the Configuring System Properties document:

Why is my thread local instance leaking data?

The leak is caused because we have a custom class for the ThreadLocalinstance, and also a custom class for the value bound to the Thread. Actually the important thing is that both classes were loaded by the webapp classloader.

You Might Also Like