Skip to content

JarFileWrapper may cause many FinalReferences causing GC pressure #28042

@HzjNeverStop

Description

@HzjNeverStop

Environment:spring boot 2.5.4 + jdk8
Create a bean to continue load class which could not be found,than use java -jar start springboot fatjar

@Component
public class TestClass implements InitializingBean {
    @Override
    public void afterPropertiesSet() throws Exception {
        new Thread(() -> {
            while (true) {
                try {
                    Class.forName("com.test.error.NotClassFound");
                } catch (ClassNotFoundException e) {
                    //ignore
                }
            }
        }).start();
    }
}

many org.springframework.boot.loader.jar.JarFileWrapper will be create which increase FinalReference time in gc:
20210917132511

when update spring boot version to 2.1.13,it's ok:
20210917132520

In normal it will not happen because LaunchedURLClassLoader has package cache,but it will happen when so bug trigger many nonexistent class load.

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions