File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1313 This makes the runtime attachment work in more environments such as minimal Docker containers.
1414 Note that the runtime attachment currently does not work for OSGi containers like those used in many application servers such as JBoss and WildFly.
1515 See the [ documentation] ( https://www.elastic.co/guide/en/apm/agent/java/master/setup-attach-cli.html ) for more information.
16+ * JDBC statement map is leaking in Tomcat if the application that first used it is udeployed/redeployed. See [ this
17+ related discussion] ( https://discuss.elastic.co/t/elastic-apm-agent-jdbchelper-seems-to-use-a-lot-of-memory/195295 ) .
1618
1719# Breaking Changes
1820 * The ` apm-agent-attach.jar ` is not executable anymore.
Original file line number Diff line number Diff line change 3535public abstract class JdbcHelper {
3636 @ SuppressWarnings ("WeakerAccess" )
3737 @ VisibleForAdvice
38- public static final WeakConcurrentMap <Object , String > statementSqlMap = new WeakConcurrentMap <>(true );
38+ public static final WeakConcurrentMap <Object , String > statementSqlMap ;
39+
40+ static {
41+ statementSqlMap = new WeakConcurrentMap <>(true );
42+ // This class will probably be loaded in the context of a request processing thread
43+ // whose context class loader is the web application ClassLoader.
44+ // This leaks the web application ClassLoader when the application is undeployed/redeployed.
45+ // Tomcat will then stop the thread because it thinks it was created by the web application.
46+ // That means that the map will never be cleared, creating a severe memory leak.
47+ statementSqlMap .getCleanerThread ().setContextClassLoader (null );
48+ }
3949
4050 /**
4151 * Maps the provided sql to the provided Statement object
You can’t perform that action at this time.
0 commit comments