Skip to content

[java] ClassTypeResolver#searchNodeNameForClass leaks memory #2911

@danberindei

Description

@danberindei

Affects PMD Version:

6.29.0

Description:

ClassTypeResolver#searchNodeNameForClass does many more ClassLoader.loadClass() calls than there are classes in the project. Because the looked up names do not exist, the calls go through all the classloaders in the hierarchy, and every classloader creates an entry for the name in its parallelLockMap.

In turn, JavaTypeDefinition#CLASS_EXACT_TYPE_DEF_CACHE holds references to the types that do exist in the project, which keep alive the classloaders of all the modules in the Maven reactor, along with their parallelLockMap.

Steps to reproduce:

  1. Set a conditional breakpoint in ClassLoader#getClassLoadingLock with condition className.contains(".get")
  2. Start a debug configuration listening on port 5005
  3. Run MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=localhost:5006" mvn pmd:pmd

Running PMD through: Maven

Metadata

Metadata

Assignees

Labels

a:bugPMD crashes or fails to analyse a file.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions