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

Bug 358099

Summary: SimpleAttributeResolver should reuse the valueCache
Product: [Modeling] TMF Reporter: Benjamin Schwertfeger <benjamin.schwertfeger>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: christian.dietrich.opensource
Version: 2.0.1   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Benjamin Schwertfeger CLA 2011-09-19 08:10:17 EDT
The valueCache inside the SimpleAttributeResolver registers for each getValue an discardingAdapter at the given element. Two SimpleAttributeResolver listening at the same Feature registers two Adapter at the containing EObject.

If you use the SimpleAttributeResolver to resolve only one value and throw it away after this, the adaper (and also the resolver) are still inside the model and never garbage colltected. (Memory Leak)

Like the qualifiedName, which is cached in the eAdapter of the Resource, the simple attribute resolver should cache the value inside the eAdapter. Other instances can reuse it and the number of Adapters is limited. An alternative not caching SimpleAttributeResolver would also do the trick sometimes.

If nothing can be changed, there should be at least a note in the javadoc that the value is cached and a SimpleAttributeResolver should be reused as much as possible.