Skip to content

Refine allocations for improved memory profile when creating a large amount of proxy instances #30499

Closed
@mp911de

Description

@mp911de

JdkDynamicAopProxy allocates a lot of objects in findDefinedEqualsAndHashCodeMethods and in the constructor via AopProxyUtils.completeProxiedInterfaces (object arrays, collection instances) to compute whether the interfaces implement hashCode/equals methods.

This effect gets visible when creating several thousand (100000s) proxy instances. It would be neat to either have a built-in cache for these values or to be able to override these features so Spring Data could supply values from its caches.

Recorded allocations:

Allocations ProxyFactory

Right now, this isn't possible because the methods are private or being called within the constructor. Also, the implementation of invoke uses several package-private fields of ProxyConfig and other protected components.

We found this aspect while debugging a more significant memory issue via spring-projects/spring-data-commons#2831

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions