Skip to content

BeanUtils.copyProperties() consumes large amount of memory #27246

Closed
@NeatGuyCoding

Description

@NeatGuyCoding

After upgrade from 5.2.x to 5.3.x, we observed large increase in YoungGC caused by huge amount of object created. After test we found that is because BeanUtils.copyProperties().

In 5.3.x, using ResolvableType to increase fitness but there is no cache which would cause there are many ResolvableType objects created and result in large memory consuming. And there is a comparasion:

TestBean testBean1 = new TestBean("1", "2", "3", "4", "5", "6", "7", "8", "1", "2", "3", "4", "5", "6", "7", "8");
TestBean testBean2 = new TestBean();
for (int i = 0; i > -1; i++) {
    BeanUtils.copyProperties(testBean1, testBean2);
    System.out.println(i);
}

the VM option is -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xmx512m, the program will exit when the memory run out.

For 5.2.x, the last i is:

444489

For 5.3.x, the last i is:

27456

That's a huge memory consuming.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions