|
|
Re: Xtext builder participant OutOfMemoryError [message #666119 is a reply to message #666015] |
Tue, 19 April 2011 08:07 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
When you navigate the model, e.g. by calling Attribute.getDomain() as in
your stacktrace, you are resolving this reference, i.e. loading the
referenced resource into the resource set. It look like this way you are
pulling everything into memory even though the builder is just loading
clusters of initial resources. I suspect this is why you're running out
of memory.
Try to figure out if what you're trying to achieve can be done with
information from the index only (i.e. without resolving elements). If
there's just a bit of data missing, and you could try to add this as
userData to the IEObjectDescriptions when indexing.
BTW, in Xtext 2.0 we have significantly reduced memory consumption.
Maybe you could give it a try?
Am 18.04.11 18:00, schrieb Rafael Angarita:
> Hello everybody,
> I'm still having memory problems when loading Xtext projects with many
> (about 15000) files. I made the optimizations mentioned in the
> Sebastian's blog and then the Xtext builer (alone) worked great.
>
> Now, I have another Eclipse project where I have the rest of the code of
> my plugin and where I implemented the IXtextBuilderParticipant interface
> to be able to do the extra proccesing needed. I made a little example of
> my builder, the only thing that it does is to print every object and its
> referenced objects. Here is the code:
>
>
> public class MyBuilderParticipant implements IXtextBuilderParticipant {
>
>
> public static final String BUILDER_ID = "MyBuilderId";
>
> public static EList<Resource> resources;
>
> @Override
> public void build(IBuildContext context, IProgressMonitor monitor)
> throws CoreException {
>
> if (context.getBuildType().equals(BuildType.FULL)){
> //full building: round 1
> for (IResourceDescription.Delta delta : context.getDeltas()) {
> if (delta.getNew() != null){
> URI uri = getObjectUrl(delta.getNew());
> if(uri != null){
> EObject eObject = context.getResourceSet().getEObject(uri, true);
> System.out.println(eObject);
> }
> }
> }
> //full building: round 2
> for (IResourceDescription.Delta delta : context.getDeltas()) {
> if (delta.getNew() != null){
> URI uri = getObjectUrl(delta.getNew());
> if(uri != null){
> EObject eObject = context.getResourceSet().getEObject(uri, true);
> updateReferences(eObject);
> }
> }
> }
> }
> }
>
> private void updateReferences(EObject data) {
>
> if (data instanceof Table){
> addTableReferences((Table) data);
> } else if (data instanceof Attribute){
> addAttributeReferences((Attribute)data);
> } else if (data instanceof Procedure){
> addProcedureReferences((Procedure)data);
> } else if (data instanceof Domain){
> addDomainReferences((Domain)data);
> }
> }
>
> private void addDomainReferences(Domain domain) {
> System.out.println(domain.getName());
> System.out.println(domain.eResource().getURI().path());
> }
>
> private void addProcedureReferences(Procedure procedure) {
> System.out.println(procedure.getName());
> System.out.println(procedure.eResource().getURI().path());
> }
>
> private void addAttributeReferences(Attribute attribute) {
> //This is the exception line:
> //at
> altagracia.builder.XtextAltagraciaBuilderParticipant.addAttr ibuteReferences
> //(XtextAltagraciaBuilderParticipant.java:97)
> Domain domain = attribute.getDomain();
> if (attribute != null && domain != null) {
> System.out.println(domain.getName());
> System.out.println(attribute.eResource().getURI().path());
> }
> }
>
> private void addTableReferences(Table table) {
>
> if (table != null) {
> System.out.println(table.getName());
> System.out.println(table.eResource().getURI().path());
> if (table.getTable() != null) {
> List<Column> Columns = table.getTable().getColumns();
> for(Column column: Columns) {
> if (column.getAttribute() != null) {
> System.out.println(column.getAttribute().getName());
> }
> }
> }
> }
> }
>
> private URI getObjectUrl(IResourceDescription file){
>
> Iterator<IEObjectDescription> it = file.getExportedObjects().iterator();
> if (it.hasNext()) {
> return it.next().getEObjectURI();
> }else{
> return null;
> }
> }
> }
>
>
> Also, I've been experimenting with the GC and memory parameters of the
> JVM too with no success. This is one of the setting I've tried:
>
>
> -Xms2000m -Xmx2500m -XX:NewSize=128m -XX:+UseConcMarkSweepGC
> -XX:CMSInitiatingOccupancyFraction=85 -XX:+UseCMSInitiatingOccupancyOnly
> -XX:CMSIncrementalDutyCycleMin=1 -XX:+CMSClassUnloadingEnabled
>
>
> After awhile, my computers gets really slow and I get error:
>
>
> java.lang.OutOfMemoryError: Java heap space
> at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1719)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:4796 )
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4360 )
> at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
> at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:81 68)
> at org.eclipse.swt.widgets.Display.eventProc(Display.java:1238)
> at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Na tive Method)
> at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS. java:2229)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3159)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2640)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 38)
> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:664)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:57)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:616)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
>
> !ENTRY org.eclipse.core.jobs 4 2 2011-04-18 11:00:14.248
> !MESSAGE An internal error occurred during: "Building workspace".
> !STACK 0
> java.lang.OutOfMemoryError: Java heap space
> at java.util.LinkedHashMap.createEntry(LinkedHashMap.java:441)
> at java.util.LinkedHashMap.addEntry(LinkedHashMap.java:423)
> at java.util.HashMap.put(HashMap.java:402)
> at
> org.eclipse.xtext.resource.containers.StateBasedContainer.do GetUriToDescription(StateBasedContainer.java:59)
>
> at
> org.eclipse.xtext.resource.impl.ResourceDescriptionsBasedCon tainer.getUriToDescription(ResourceDescriptionsBasedContaine r.java:48)
>
> at
> org.eclipse.xtext.resource.containers.StateBasedContainer.ge tResourceDescriptions(StateBasedContainer.java:50)
>
> at
> org.eclipse.xtext.resource.containers.FilterUriContainer.get ResourceDescriptions(FilterUriContainer.java:31)
>
> at
> org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider.cr eateContainerScope(DefaultGlobalScopeProvider.java:99)
>
> at
> org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider.cr eateContainerScopeWithContext(DefaultGlobalScopeProvider.jav a:95)
>
> at
> org.eclipse.xtext.scoping.impl.DefaultGlobalScopeProvider.ge tScope(DefaultGlobalScopeProvider.java:51)
>
> at
> org.eclipse.xtext.scoping.impl.AbstractGlobalScopeDelegating ScopeProvider.getGlobalScope(AbstractGlobalScopeDelegatingSc opeProvider.java:32)
>
> at
> org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalSc opeProvider.getScope(ImportedNamespaceAwareLocalScopeProvide r.java:136)
>
> at
> org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalSc opeProvider.getScope(ImportedNamespaceAwareLocalScopeProvide r.java:140)
>
> at
> org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvi der.delegateGetScope(AbstractDeclarativeScopeProvider.java:7 2)
>
> at
> org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvi der.getScope(AbstractDeclarativeScopeProvider.java:102)
>
> at
> org.eclipse.xtext.linking.impl.DefaultLinkingService.getScop e(DefaultLinkingService.java:49)
>
> at
> org.eclipse.xtext.linking.impl.DefaultLinkingService.getLink edObjects(DefaultLinkingService.java:103)
>
> at
> org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObjec t(LazyLinkingResource.java:94)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObje ct(ResourceSetImpl.java:219)
>
> at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java: 202)
> at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java: 262)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResolveProxy(Ba sicEObjectImpl.java:1483)
>
> at
> org.xtext.altagracia.attribute.impl.AttributeImpl.getDomain( AttributeImpl.java:258)
>
> at
> altagracia.builder.MyBuilderParticipant.addAttributeReferenc es(XtextAltagraciaBuilderParticipant.java:97)
>
> at
> altagracia.builder.MyBuilderParticipant.updateReferences(Xte xtAltagraciaBuilderParticipant.java:76)
>
> at
> altagracia.builder.MyBuilderParticipant.build(XtextAltagraci aBuilderParticipant.java:58)
>
> at
> org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.bu ild(RegistryBuilderParticipant.java:60)
>
> at
> org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBui lder.java:157)
> at
> org.eclipse.xtext.builder.impl.XtextBuilder.fullBuild(XtextB uilder.java:180)
>
> at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuild er.java:78)
> at
> org.eclipse.core.internal.events.BuildManager$2.run(BuildMan ager.java:629)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
>
>
> I marked in my builder code the line that causes the error.
>
> I am really stuck here. What could I do? The code of my builder is very
> simple and the Xtext builder alone works perfectly
>
> Thank you very much for your help!!
>
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03345 seconds