0
votes

I've created a new XText project with a single xtext file defining the grammar, and without changing any other files in the project. The grammar I defined took about 150 lines and when trying to "generate language infrastructure" everything went smoothly, but then I expanded it a bit and now that infrastructure generation fails on:

460476 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Java heap space
java.lang.OutOfMemoryError: Java heap space
    at java.util.ArrayList.iterator(Unknown Source)
    at org.eclipse.xtext.util.formallang.PdaUtil$TraversalItem.<init>(PdaUtil.java:247)
    at org.eclipse.xtext.util.formallang.PdaUtil.newItem(PdaUtil.java:531)
    at org.eclipse.xtext.util.formallang.PdaUtil.filterEdges(PdaUtil.java:451)
    at org.eclipse.xtext.serializer.analysis.ContextTypePDAProvider.createPDA(ContextTypePDAProvider.java:178)
    at org.eclipse.xtext.serializer.analysis.ContextTypePDAProvider.getContextTypePDA(ContextTypePDAProvider.java:188)
    at org.eclipse.xtext.serializer.analysis.SyntacticSequencerPDAProvider.getPDA(SyntacticSequencerPDAProvider.java:604)
    at org.eclipse.xtext.generator.serializer.SyntacticSequencerUtil.getAllPDAs(SyntacticSequencerUtil.java:59)
    at org.eclipse.xtext.generator.serializer.SyntacticSequencerUtil.getAllAmbiguousTransitions(SyntacticSequencerUtil.java:79)
    at org.eclipse.xtext.generator.serializer.SyntacticSequencerUtil.getAllAmbiguousTransitionsBySyntax(SyntacticSequencerUtil.java:90)
    at org.eclipse.xtext.generator.serializer.AbstractSyntacticSequencer.getFileContents(AbstractSyntacticSequencer.java:95)
    at org.eclipse.xtext.generator.serializer.SerializerFragment.generate(SerializerFragment.java:97)
    at org.eclipse.xtext.generator.Xtend2GeneratorFragment.generate(Xtend2GeneratorFragment.java:66)
    at org.eclipse.xtext.generator.Xtend2GeneratorFragment.generate(Xtend2GeneratorFragment.java:59)
    at org.eclipse.xtext.generator.CompositeGeneratorFragment.generate(CompositeGeneratorFragment.java:92)
    at org.eclipse.xtext.generator.LanguageConfig.generate(LanguageConfig.java:113)
    at org.eclipse.xtext.generator.Generator.generate(Generator.java:361)
    at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:128)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
    at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
    at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)

I checked my launch settings in the Eclipse configuration for that action and saw that until that time it was -Xmx512m. I tried to increase that number and all it did was that now the action takes more time before crashing on the same error. I got all the way up to -Xmx3000m - didn't want to try more on my 4Gb machine.

I want to stress that all I did was create a new XText project and modify the default "Hello X!" grammar to by a 200-line grammar definition of my own. My grammar compiles just fine, giving no warnings or errors. What caused this memory error to be introduced, and how can I fix it?

I've found this related blog post but I admit the proposed fixes there are beyond my level, I'm not sure what precisely I need to do and whether it will fix the problem at all.

1
Which Xtext version do you use? Could you possibly file a ticket with your grammar attached? Do you see any warnings in the grammar?Sebastian Zarnekow
@SebastianZarnekow Xtext version 2.3.0, downloaded as a complete Eclipse 4.2 distribution from eclipse.org/Xtext/download.html. There are no warnings or errors in the grammar. If you believe this to be some wider Xtext issue then I guess I can try to file a ticket... though it seems I need an account for that :\Oak
I had something similar once. My DSL is linked to all files with extension '*.script'. In my workspace I had a file 'db.script' which belonged to a database and was quite big (around 10MB), but had nothing to do with my DSL. after I deleted the file, everything went smoothly again. perhaps it's something similar here?moeTi
@moeTi I'm confused, it sounds like you're describing a problem when opening a DSL file, while my problem is when building the language infrastructure. In any case, my grammar file does not refer to any other file except common.Terminals.Oak
@Oak I'm sorry, I misread your question. forget what I said ;-)moeTi

1 Answers

0
votes

I was finally able to narrow down the issue:

Datatype:
  Rule1 '=' Rule2 Rule3 INT Rule4 etc etc...

Failed on out-of-memory; while

Datatype:
  name=Rule1 '=' Rule2 Rule3 INT Rule4 etc etc...

Works fine, even with the original -Xmx512m. The only difference is assigning a name to one of the rules. I did not realize naming the rules is so important, I thought it's something I can largely skip if I only care about syntactically-correct DSL files and did not intend to process them further, but I guess I was wrong...