Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361382 - Memory leaks in profiling.ext
Summary: Memory leaks in profiling.ext
Status: CLOSED WONTFIX
Alias: None
Product: M2T
Classification: Modeling
Component: Xpand (show other bugs)
Version: 1.1.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: M3   Edit
Assignee: Karsten Thoms CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-19 08:15 EDT by Tatiana Fesenko CLA
Modified: 2020-04-30 13:53 EDT (History)
1 user (show)

See Also:
karsten.thoms: iplog+
karsten.thoms: juno+


Attachments
Test project demonstrating the issue. (13.25 KB, application/zip)
2011-10-19 08:15 EDT, Tatiana Fesenko CLA
no flags Details
Proposed patch (2.03 KB, patch)
2011-10-19 08:35 EDT, Tatiana Fesenko CLA
no flags Details | Diff
Modified Test Projects (415.00 KB, application/binary)
2011-10-19 08:48 EDT, Karsten Thoms CLA
no flags Details
Patch with caching profiles (4.16 KB, patch)
2011-10-19 10:17 EDT, Tatiana Fesenko CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tatiana Fesenko CLA 2011-10-19 08:15:41 EDT
Created attachment 205511 [details]
Test project demonstrating the issue.

Create a transformation that applies a profile. Run it several times in the same thread - "java.lang.OutOfMemoryError: Java heap space" after approximately 30 iterations. 

I am using Eclipse Indigo with Xpand 1.1.1.

The problem is that XmiReader#load() loads profile in a new ResourceSet instead of using the resource set of the element.

I am attaching a sample project demonstrating this issue.
Comment 1 Tatiana Fesenko CLA 2011-10-19 08:35:09 EDT
Created attachment 205517 [details]
Proposed patch
Comment 2 Karsten Thoms CLA 2011-10-19 08:48:02 EDT
Created attachment 205520 [details]
Modified Test Projects

Added imported packages and org.antlr.runtime. Copied Xtend Component several times.

This way the bug got reproducable in my runtime workbench.
Comment 3 Karsten Thoms CLA 2011-10-19 09:02:50 EDT
This won't work that way, at least not generally. The transformed Model instance in your example is not attached to Resource yet when trying to apply the profile. Thus, 
  element.eResource()
will return null and raises a NullPointerException in 
  element.eResource().getResourceSet()

The element's ResourceSet can only be taken when the element is attached to a resources. Otherwise, the profile must still be loaded in its own ResourceSet.
Comment 4 Karsten Thoms CLA 2011-10-19 09:22:24 EDT
The solution is actually that the resource must be unloaded again.

	        result = (Element) r.getContents().get(0);
	        
        	// unload the resource when it was loaded in a new ResourceSet
        	// otherwise this leads to memory leak, see Bug#361382
        	r.unload();

	        return result;

Thanks for reporting and the example!
Comment 5 Tatiana Fesenko CLA 2011-10-19 09:50:49 EDT
Reopened - Java heap space after ~ 4*(70 -- number of XtendCompoments) = 280 iterations.

This issue is important while running a workflow on server, as a part of service. In that case the same workflow is executed many times with different input models.
Comment 6 Tatiana Fesenko CLA 2011-10-19 10:17:38 EDT
Created attachment 205531 [details]
Patch with caching profiles

I used "1" as a default size of HashMap assuming that in most cases the user needs only one profile.
Comment 7 Karsten Thoms CLA 2020-04-30 13:53:56 EDT
This is a batch close of open M2T Xpand bugs. It is not planned work on this component in the foreseeable future. If you think this issue needs to be solved and you plan to contribute a fix then feel free to reopen it.