Community
Participate
Working Groups
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.
Created attachment 205517 [details] Proposed patch
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.
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.
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!
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.
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.
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.