Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » JAVA HEAP SPACE (OUT OF MEMEORY)(For large and many resources (1000 files) out of memory)
JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795550] Tue, 25 September 2018 08:38 Go to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Hello,
I get the below error, when I have more than 1000 files and I am trying to build project. Works well, when I have less files in project.
I am using Xtext 2.13.
Any suggestion that what is going wrong ?

java.lang.OutOfMemoryError: Java heap space
	at java.lang.AbstractStringBuilder.<init>(Unknown Source)
	at java.lang.StringBuilder.<init>(Unknown Source)
	at org.eclipse.xtext.parser.antlr.XtextTokenStream.toString(XtextTokenStream.java:81)
	at org.antlr.runtime.CommonTokenStream.toString(CommonTokenStream.java:352)
	at org.eclipse.xtext.parser.antlr.AbstractInternalAntlrParser.parse(AbstractInternalAntlrParser.java:548)
	at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.doParse(AbstractAntlrParser.java:102)
	at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.parse(AbstractAntlrParser.java:84)
	at org.eclipse.xtext.parser.antlr.AbstractAntlrParser.doParse(AbstractAntlrParser.java:62)
	at org.eclipse.xtext.parser.AbstractParser.parse(AbstractParser.java:33)
	at org.eclipse.xtext.resource.XtextResource.doLoad(XtextResource.java:176)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doLoad(LazyLinkingResource.java:100)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	at org.eclipse.xtext.resource.XtextResourceSet.getResource(XtextResourceSet.java:265)
	at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:25)
	at org.eclipse.xtext.builder.resourceloader.SerialResourceLoader$1.next(SerialResourceLoader.java:47)
	at org.eclipse.xtext.builder.resourceloader.AbstractResourceLoader$CheckedLoadOperation.next(AbstractResourceLoader.java:77)
	at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.writeNewResourceDescriptions(ClusteringBuilderState.java:382)
	at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.doUpdate(ClusteringBuilderState.java:135)
	at org.eclipse.xtext.builder.builderState.AbstractBuilderState.update(AbstractBuilderState.java:116)
	at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:287)
	at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:267)
	at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:161)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304)


Thanks and regards,
Virag Purnam

Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795551 is a reply to message #1795550] Tue, 25 September 2018 08:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14075
Registered: July 2009
Senior Member
this is expected behaviour. memory is not a infinite resource.
you can increase memory (-Xmx) or enable resource clustering (bind org.eclipse.xtext.resource.clustering.DynamicResourceClusteringPolicy as org.eclipse.xtext.resource.clustering.IResourceClusteringPolicy via overridingGuiceModule and ui module - this might lead to much longer build times)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Tue, 25 September 2018 08:42]

Report message to a moderator

Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795552 is a reply to message #1795551] Tue, 25 September 2018 08:50 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Thanks for the reply.
Will this solve problem at customer's end?
Because they might have another project with 2000 files.
And If you can share example for how to bind DynamicResourceClusteringPolicy, this will help me.
Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795554 is a reply to message #1795550] Tue, 25 September 2018 08:59 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 748
Registered: July 2009
Location: Dortmund, Germany
Senior Member

2000 files are quite some, but nothing Xtext could not handle. How large do the files get?
Anyway, Christian's hints are the right one to start with.
Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795558 is a reply to message #1795554] Tue, 25 September 2018 09:15 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Thanks and I agree with you.
Is the below code snippet is correct way to bind DynamicResourceClusteringPolicy?



public class MyModule implements Module {

	public MyModule() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void configure(Binder binder) {
		binder.bind(IResourceClusteringPolicy.class).to(DynamicResourceClusteringPolicy.class);
	}
	

}



Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795573 is a reply to message #1795558] Tue, 25 September 2018 12:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14075
Registered: July 2009
Senior Member
Yes. Use that with the override. Guice module extension point

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795606 is a reply to message #1795573] Wed, 26 September 2018 08:13 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
After adding DynamicResourceClusteringPolicy to UiModule, I started getting below exception in Activator class.

Failed to create injector for org.xtext.example.mydsl.MyDsl

1) No implementation for org.eclipse.xtext.builder.resourceloader.IResourceLoader annotated with @com.google.inject.name.Named(value=org.eclipse.xtext.builder.resourceloader.crossLinking) was bound.
  while locating org.eclipse.xtext.builder.resourceloader.IResourceLoader annotated with @com.google.inject.name.Named(value=org.eclipse.xtext.builder.resourceloader.crossLinking)
    for field at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.crossLinkingResourceLoader(Unknown Source)
  at org.eclipse.xtext.service.MethodBasedModule.configure(MethodBasedModule.java:57)

2) No implementation for org.eclipse.xtext.builder.resourceloader.IResourceLoader annotated with @com.google.inject.name.Named(value=org.eclipse.xtext.builder.resourceloader.globalIndex) was bound.
  while locating org.eclipse.xtext.builder.resourceloader.IResourceLoader annotated with @com.google.inject.name.Named(value=org.eclipse.xtext.builder.resourceloader.globalIndex)
    for field at org.eclipse.xtext.builder.clustering.ClusteringBuilderState.globalIndexResourceLoader(Unknown Source)
  at org.eclipse.xtext.service.MethodBasedModule.configure(MethodBasedModule.java:57)


Help needed here?
Not sure what is going wrong?
Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795611 is a reply to message #1795606] Wed, 26 September 2018 08:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14075
Registered: July 2009
Senior Member
what did you exactly do?
i assume you simply did the same configure which is a bad idea when not calling super.
a terrible terrible bad idea.

in Xtext runtime and ui module such a binding would ususally look like

def Class<? extends IResourceClusteringPolicy> bindIResourceClusteringPolicy() {
return DynamicResourceClusteringPolicy
}

or
def void configureIResourceClusteringPolicy(Binder binder) {
binder.bind(IResourceClusteringPolicy).to(DynamicResourceClusteringPolicy)
}

please read the docs on dependency injection



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 26 September 2018 08:29]

Report message to a moderator

Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795615 is a reply to message #1795611] Wed, 26 September 2018 08:48 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Ok.. I have done the below mentioned changes.

New Module:
public class MyModule implements Module {

	public MyModule() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void configure(Binder binder) {
		binder.bind(IResourceClusteringPolicy.class).to(DynamicResourceClusteringPolicy.class);
	}
	

}


plugin.xml
<extension point="org.eclipse.xtext.ui.shared.overridingGuiceModule">
    	<module
        	class="org.xtext.example.mydsl.ui.MyModule">
    	</module>
    </extension>


MyDslUiModule.xtend
def Class<? extends IResourceClusteringPolicy> bindIResourceClusteringPolicy() {
		return DynamicResourceClusteringPolicy
	}


Am I doing it correct?
Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795619 is a reply to message #1795615] Wed, 26 September 2018 09:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14075
Registered: July 2009
Senior Member
Yes it looks ok, does it work?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795622 is a reply to message #1795619] Wed, 26 September 2018 09:17 Go to previous messageGo to next message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Yeah this works good.
I have done similar thing for ClusteringBuilderState. That was creating problem.
Can't we do same for ClusteringBuilderState? Like below.



public class MyModule implements Module {

	public MyModule() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void configure(Binder binder) {
		binder.bind(ClusteringBuilderState.class).to(MyClusteringBuilderState.class);
		binder.bind(IResourceClusteringPolicy.class).to(DynamicResourceClusteringPolicy.class);
	}
	

}


<extension point="org.eclipse.xtext.ui.shared.overridingGuiceModule">
    	<module
        	class="org.xtext.example.mydsl.ui.MyModule">
    	</module>
    </extension>


def Class<? extends IResourceClusteringPolicy> bindIResourceClusteringPolicy() {
		return DynamicResourceClusteringPolicy
	}
	
	def Class<? extends ClusteringBuilderState> bindClusteringBuilderState() {
		return MyClusteringBuilderState
	}


Why its is not working for ClusteringBuilderState? I want to modify this class.
Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795624 is a reply to message #1795622] Wed, 26 September 2018 09:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14075
Registered: July 2009
Senior Member
cause clustering builder state is shared. => you have to do it with MyModule and it will affect all dsls

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: JAVA HEAP SPACE (OUT OF MEMEORY) [message #1795627 is a reply to message #1795624] Wed, 26 September 2018 09:26 Go to previous message
Virag Purnam is currently offline Virag PurnamFriend
Messages: 135
Registered: June 2014
Senior Member
Ok.
That means I dont have to add it to UiModule.
Just below line will do the job incase of ClusteringBuilderState.

public class MyModule implements Module {

	public MyModule() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void configure(Binder binder) {
		binder.bind(ClusteringBuilderState.class).to(MyClusteringBuilderState.class);
	}
	

}


Thanks a lot. :) It was really helpful.

[Updated on: Wed, 26 September 2018 09:31]

Report message to a moderator

Previous Topic:How to implement scoping and validation for an element at same time
Next Topic:How to implement scoping and validation for an element at same time
Goto Forum:
  


Current Time: Wed Oct 20 07:30:18 GMT 2021

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

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

Back to the top