Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 312252

Summary: AnnotatedConstructor creates a hash map even to hold one annotation, which causes considerable memory overhead.
Product: z_Archived Reporter: Mark Hills <Mark.Hills>
Component: IMPAssignee: Jurgen Vinju <jurgen.vinju>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: jurgen.vinju, lankamp, rfuhrer
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch to specialize Annotated Constructors for 1, 2 and 3 annotations. none

Description Mark Hills CLA 2010-05-10 09:25:51 EDT
Build Identifier: 20100218-1602

Class org.eclipse.imp.pdb.facts.impl.fast.AnnotatedConstructor uses a hashmap to store the annotations on the constructor, even in cases where there is just one annotation. If a large number of uses of this class have just one annotation, this leads to considerable memory overhead. It may work better to have a specialized version of the AnnotatedConstructor tailored to just one annotation, switching over to the current version (for arbitrary numbers of annotations) automatically when needed.

Reproducible: Always

Steps to Reproduce:
1. Run a program that creates a large number of constructors.
2. Assign a single annotation to each.
3. Watch memory usage grow.
Comment 1 Jurgen Vinju CLA 2010-05-11 05:29:05 EDT
Created attachment 167883 [details]
Patch to specialize Annotated Constructors for 1, 2 and 3 annotations.

This code was written by Mark Hills (CWI)
Comment 2 Jurgen Vinju CLA 2010-05-11 05:31:45 EDT
Applied the patch. The bug is left open, since the SharedValueFactory implementation still suffers from this problem.
Comment 3 Jurgen Vinju CLA 2010-05-11 05:37:54 EDT
The shared implementation inherits from the fast implementation, thus the bug is solved in both.