Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.7.1: uninferredTypeArgumentScanner consumes significant amount of memory in AnnotatedTypeMirror #3851

Closed
vlsi opened this issue Nov 3, 2020 · 1 comment · Fixed by #3852
Assignees

Comments

@vlsi
Copy link
Contributor

vlsi commented Nov 3, 2020

Apparently, verification of Calcite codebase requires to bump -Xmx to 2g or something like that, and it turns out noticeable memory is taken by SimpleAnnotatedTypeScanner:

/** The implementation of the visitor for #containsUninferredTypeArguments. */
private final SimpleAnnotatedTypeScanner<Boolean, Void> uninferredTypeArgumentScanner =
new SimpleAnnotatedTypeScanner<>(
(type, p) ->
type.getKind() == TypeKind.WILDCARD
&& ((AnnotatedWildcardType) type).isUninferredTypeArgument(),
Boolean::logicalOr,
false);

Could it be a static instance and/or ThreadLocal?

NullnessAnnotatedTypeFactory consumed ~50MiB

Снимок экрана 2020-11-04 в 1 10 30

~ 50% of that was consumed by empty IdentityHashMap in SimpleAnnotatedTypeScanner

Снимок экрана 2020-11-04 в 1 11 01

There are 72226 SimpleAnnotatedTypeScanner instances which are referenced from AnnotatedTypeMirror$... classes

Снимок экрана 2020-11-04 в 1 11 29

@vlsi vlsi changed the title uninferredTypeArgumentScanner consumes significant amount of memory in AnnotatedTypeMirror 3.7.1: uninferredTypeArgumentScanner consumes significant amount of memory in AnnotatedTypeMirror Nov 3, 2020
@smillst
Copy link
Member

smillst commented Nov 3, 2020

Thanks for tracking this down! I opened #3852 which clears the IdentityHashMap as soon as possible. That should help, but I haven't tested it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants