Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361907 - Match and diff models are not GC'ed upon compare editor close
Summary: Match and diff models are not GC'ed upon compare editor close
Status: CLOSED FIXED
Alias: None
Product: EMFCompare
Classification: Modeling
Component: Core (show other bugs)
Version: 1.3   Edit
Hardware: PC Windows 7
: P3 critical with 1 vote (vote)
Target Milestone: Juno SR2   Edit
Assignee: EMF Compare CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 364270 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-25 06:58 EDT by Victor Roldan Betancort CLA
Modified: 2013-01-23 07:26 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Roldan Betancort CLA 2011-10-25 06:58:46 EDT
If you execute comparison over two big models and open the result on the compare editor:

ComparisonResourceSnapshot snapshot = DiffFactory.eINSTANCE.createComparisonResourceSnapshot();
snapshot.setDiff(diffModel);
snapshot.setMatch(matchModel);
ModelCompareEditorInput editorInput = new ModelCompareEditorInput(snapshot);
CompareUI.openCompareEditorOnPage(editorInput, page);

One can determine, using tools like VisualVM, that diff and match models are kept in the heap and not reclaimed. If you execute sequential model comparisons and open in the editor, the JVM instance will eventually run out of memory.
Comment 1 Victor Roldan Betancort CLA 2011-10-25 07:07:45 EDT
Some of the possible culprits being strongly-referenced:

- ModelCompareEditorInput (i.e, org.eclipse.ui.internal.Workbench.editorHistory)
- ModelCompareInput (among others, by ModelCompareEditorInput)
- ModelComparator (by ModelComparator.INSTANCES)
Comment 2 Victor Roldan Betancort CLA 2011-10-26 05:57:23 EDT
From the Laurent Goubet at the newsgroup:

"If the ModelComparator is not the culprit, you could also try the EMFModelProvider or EMFResourceMapping. These two are part of recent development on the integration with logical models, and are still a work in progress. I know that we load the two/three distinct resource sets from there, and I still have a FIXME pending to try and find a way to unload those resources. However, I confess I still don't know "where" or "when" to unload these. This particular issue is a pending work and will be completed by 1.3, but that might be the candidate you're missing to determine where the leak(s?) come from"
Comment 3 Laurent Goubet CLA 2011-10-28 10:47:56 EDT
Victor,

I have isolated a number of leaks with UML models, though could not try and get rid of everyone. This is my current task and should be completed sometime next week. For the record, ModelComparator does leak all compared Resources, as does AdapterUtils.FACTORY (this is an historic one, I wonder whether the behavior of the UMLAdapterFactory changed since then or if we simply failed to discover this leak). Unfortunately that second one is really tricky to get rid of.
Comment 4 Laurent Goubet CLA 2011-11-02 09:26:43 EDT
Victor,

The second source of memory leaks I isolated (AdapterUtils) seem to have been the last. I no longer see strong references to EMF objects with these two changes, and my heap goes back to 50-60Mo when I force a garbage collection through Eclipse.

Can you verify the fixes with the latest code from Git, or would you rather I build a new integration version?
Comment 5 Victor Roldan Betancort CLA 2011-11-02 09:53:44 EDT
Laurent,

thanks for the effort. I'll give a check by the end of the week.
I can fetch the code from GIT, its not necessary to kick a build.

Good Work!
Víctor
Comment 6 Victor Roldan Betancort CLA 2011-11-04 08:37:26 EDT
Hi Laurent,

I've been checking the recent changes. It seems the ModelComparator strong references are gone. However, from what I've tested, leaks still persist. After 2 comparisons, the heap gets full, and once I close the editor, forcing GC doesn't seem to lower the heap.

A heap dump reveals that the only ones referencing the the 2 DiffModelImpl and 2 MatchModelImpl existing instances are:

- ComparisonResourceSetSnapshotImpl
- ModelCompareInput

If you guys are not experiencing this issue, I'll try to work on it when I get some time (we are in the last iteration of our current project).

Cheers!
Víctor
Comment 7 Laurent Goubet CLA 2011-11-04 09:17:31 EDT
Victor, could you provide us with sample models n which you experience this? I used somehow big models to try this, and haven't seen my heap grow too much (at least, when closing the editor the heap space can be retrieved).
Comment 8 Victor Roldan Betancort CLA 2011-11-04 09:27:23 EDT
Laurent,

I'm afraid our models contain client information so we are not allowed to share that. My heap grows to 768mb on an 32-bit JVM instance. However, the process is not just comparison, there is a lot of pre-processing of the models before comparing. I create a test-plugin that does all the pre-processing of our models and then compares and opens the compare editor.

So as you see there is other proprietary processes going on, so I want to make sure there isn't anything wrong in our code. However, profiling pointed out to code related with the comparison editor.

Given the situation, I can only offer you guys feedback and to fix this by myself.
Comment 9 Cedric Brun CLA 2011-11-21 04:58:12 EST
*** Bug 364270 has been marked as a duplicate of this bug. ***
Comment 10 Laurent Goubet CLA 2013-01-17 05:25:42 EST
There are no more "strong" references that leak when the comparison editor is closed, at least not any that I could observe since we last looked at that bug, two years ago.

EMF Compare 1.3 is pretty clean as far as memory leaks are concerned. Closing.