Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Memory Leak with TextUtils(OCL Validation / Diagnostician)
Memory Leak with TextUtils [message #1721159] Mon, 25 January 2016 10:39 Go to next message
Michael Longo is currently offline Michael LongoFriend
Messages: 8
Registered: July 2015
Junior Member
Hello,

I'm trying to implement some OCL validation into my RCP Application. To do so, I'm using Accuracy (a plugin that comes from KitAlpha and that allows you to register your OCLs as EMF Constraints) and I noticed that every time I called the Diagnostician from my Editor and then closed the editor, my model wasn't freed by the GC.

After futher investigation, it appeared that org.eclipse.emf.validation.internal.util.TextUtils keeps a static reference to my model's eobject.

And here is how it happens:
- AbstractOCLModelConstraint.validate calls AbstractValidationContext.createFailureStatus
- which calls TextUtils.formatMessage
- which calls TextUtils.formatScalarValue
- which calls TextUtils.getText
- which calls ComposedAdapterFactory.adapt (via its static attribute 'factory')
- which calls ComposedAdapterFactory.getFactoryForTypes
- which calls ComposedAdapterFactory.addAdapterFactory that adds my ItemProviderAdapterFactory to its 'adapterFactories' attribute.

As a result of that, I have TextUtils that has a final static reference to a ComposedAdapterFactory which contains a reference to my ItemAdapterFactory which contains a reference to my XXXItemProvider which contains a reference to my XXX eobject via its target attribute.

So my main question is : do I have a bad setup that leads to this issue, or is the static factory of TextUtils the issue here?

TextUtils.getText(EObject) line: 73   
TextUtils.formatScalarValue(Object) line: 197         
TextUtils.formatMessage(String, Object...) line: 161           
GetBatchConstraintsOperation$1(AbstractValidationContext).createFailureStatus(Object...) line: 392   
OCLConstraint(AbstractOCLModelConstraint<C,CT,CLS,E>).validate(IValidationContext) line: 162     
OCLConstraint.validate(IValidationContext) line: 72            
BatchValidator(AbstractValidator<T>).evaluateConstraints(AbstractValidationContext, List<IStatus>) line: 241            
BatchValidator.validate(AbstractValidationContext, EObject, GetBatchConstraintsOperation, List<IStatus>) line: 264            
BatchValidator.validate(ITraversalStrategy, List<IStatus>, AbstractValidationContext, Collection<EObject>, GetBatchConstraintsOperation, Set<IClientContext>) line: 211     
BatchValidator.doValidate(Collection<EObject>, Set<IClientContext>) line: 149  
BatchValidator(AbstractValidator<T>).validate(Collection<? extends T>) line: 147          
BatchValidator(AbstractValidator<T>).validate(T) line: 126 
BatchValidator.validate(EObject, IProgressMonitor) line: 117         
EValidatorAdapter.validate(EClass, EObject, DiagnosticChain, Map<Object,Object>) line: 164 
Diagnostician.doValidate(EValidator, EClass, EObject, DiagnosticChain, Map<Object,Object>) line: 171         
Diagnostician.validate(EClass, EObject, DiagnosticChain, Map<Object,Object>) line: 158         
Diagnostician.validate(EObject, DiagnosticChain, Map<Object,Object>) line: 137           
Diagnostician.validate(EObject) line: 108     


(Developping with/for Eclipse Luna)
Re: Memory Leak with TextUtils [message #1721167 is a reply to message #1721159] Mon, 25 January 2016 12:10 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 275
Registered: December 2015
Senior Member
On 25-Jan-16 11:40, Michael Tiller wrote:

> As a result of that, I have TextUtils that has a final static reference
> to a ComposedAdapterFactory which contains a reference to my
> ItemAdapterFactory which contains a reference to my XXXItemProvider
> which contains a reference to my XXX eobject via its target attribute.
>
> So my main question is : do I have a bad setup that leads to this issue,
> or is the static factory of TextUtils the issue here?

Maybe I don't read everything correctly, but shouldn't Resource.unload()
clear the adapters list for every object, which in turn would call
unsetTarget() (BasicNotifierImpl$EAdapterList line 150) so maybe the
issue is somewhere else?

Felix
Re: Memory Leak with TextUtils [message #1721174 is a reply to message #1721167] Mon, 25 January 2016 13:21 Go to previous message
Michael Longo is currently offline Michael LongoFriend
Messages: 8
Registered: July 2015
Junior Member
OK, I'll probably look stupid, but I just didn't know about the Resource.unload() method...

It seems to fix the issue, so yeah, thank you!

If it appears it doesn't solve the issue, I'll come back to this topic, but I have good hopes it's ok now.

Thanks again.
Previous Topic:Show and edit attributes of referenced Element in properties view
Next Topic:Thanks for the version management tool
Goto Forum:
  


Current Time: Wed Sep 19 05:55:47 GMT 2018

Powered by FUDForum. Page generated in 0.01985 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top