Opened 44 hours ago

Last modified 20 hours ago

#2342 new enhancement

Get rid of ThreadLocal:s

Reported by: Nicklas Nordborg Owned by: everyone
Priority: minor Milestone: BASE 3.20.3
Component: core Version:
Keywords: Cc:

Description

I see some warnings in the catalina.out log file:

Jan 10, 2025 9:42:40 AM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SEVERE: The web application [lorry] created a ThreadLocal with key of type [java.lang.ThreadLocal] 
(value [java.lang.ThreadLocal@2ad4909d]) and a value of type [net.sf.basedb.core.SessionControl.ClientInfo] 
(value [net.sf.basedb.core.SessionControl$ClientInfo@4b880ae3]) but failed to remove it when the web application was stopped.
 Threads are going to be renewed over time to try and avoid a probable memory leak.

There is a ThreadLocal variable in the SessionControl class that is keeping track of the "current client". This is a feature that was introduced in #2250 (BASE 3.19) that makes it possible for extensions to be seen as separate clients.

Change History (1)

comment:1 by Nicklas Nordborg, 20 hours ago

In 8336:

References #2342: Get rid of ThreadLocal:s

Re-factored the implementation in SessionControl so that it uses a WeakHashMap with a Thread as key instead of a ThreadLocal. This should make sure that unused items are garbage collected whenever the SessionControl is closed or when the thread dies.

Note: See TracTickets for help on using tickets.