7 Replies Latest reply on Jan 27, 2009 7:01 PM by kaliatech

# FreeMarker IDE Hangs Consistently

Does anyone else have a problem with the Freemarker plug-in hanging after a certain amount of time?

It happens to me fairly consistently when making changes to a larger FreeMarker template. It seems to happen, after a certain amount of time, exactly when I make change in the editor window that causes the content to get reparsed. I often see the outline view flash when it happens. When it happens, Eclipse becomes completely unresponsive, including the painter thread. (The Eclipse GUI stops updating). The only way to recover is to ctrl-alt-delete Eclipse. I don't have problems with Eclipse hanging any other time.

These hangs have been happening to me for the past ...two years?, using multiple versions of Eclipse and the FreeMarker plugin. I haven't seen others similar postings about this anywhere, so perhaps it has something subtle to do with how I set up my templates/HTML code specifically? I've also tried multiple memory settings, etc., all to no avail. It's a real pain. I tried switching to Intellij for a while as it's has an okay freemarker plugin, but I'd prefer to stay in Eclipse.

Fwiw:
- Windows XP, SP2
- Eclipse 3.4.1 (M20080911-1700)
- FreeMarker IDE 1.0.2.GA

If anyone has suggestions on how to debug this further, please let me know. I don't see a stack trace, JVM dump, or any other useful info. from the hangs. (Perhaps I can try running Eclipse in a console window and then try ctrl-breaking the java process when it hangs? ...assuming that's possible on Windows with Eclipse.)

• ###### 1. Re: FreeMarker IDE Hangs Consistently

Forgive me if you've already done this, but I have to ask... have you increased the default permgen or heap space for Eclipse?

http://wiki.eclipse.org/IRC_FAQ#I.27m_having_memory.2C_heap.2C_or_permgen_problems.2C_what_can_I_do.3F

On windows you can also CTRl_ALT-DEL to get the Task Manager, and kill processes from there, if you're not running Eclipse in a console. If you do run in console, you can also get osgi debugging information:

http://wiki.eclipse.org/IRC_FAQ#How_do_I_debug_Eclipse.3F_How_can_I_see_what_plugins_are_being_started.3F_How_do_I_start_the_OSGi_console.3F

• ###### 2. Re: FreeMarker IDE Hangs Consistently

Thanks for the reply. I have used adjusted the memory settings previously, and that did not make a difference. Fwiw, I'm currently using:

-vm c:\jdk-1.6\bin -vmargs -Xms128M -Xmx1024M -XX:PermSize=256M -XX:MaxPermSize=512M


Your link to FAQ entries pointed me to the workspace log though, which I hadn't looked at previously. Looking there after crashing again (just now), I see the stack trace below that seems to orginate in the FreeMarker plugin. I've only pasted part of it here. It seems a number of unhandled exceptions get thrown once this starts. I can send the entire trace to whoever wants it.

Should I post a JIRA issue for this? (I definitely would if anyone else confirmed they have same problem.)

-----------------
!ENTRY org.eclipse.ui 4 0 2009-01-27 14:06:20.953
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTError: No more handles
at org.eclipse.swt.SWT.error(SWT.java:3803)
at org.eclipse.swt.SWT.error(SWT.java:3695)
at org.eclipse.swt.SWT.error(SWT.java:3666)
at org.eclipse.swt.internal.ImageList.copyWithAlpha(ImageList.java:175)
at org.eclipse.swt.internal.ImageList.set(ImageList.java:405)
at org.eclipse.swt.widgets.Tree.imageIndex(Tree.java:3618)
at org.eclipse.swt.widgets.TreeItem.setImage(TreeItem.java:1685)
at org.eclipse.jface.viewers.TreeViewerRow.setImage(TreeViewerRow.java:166)
at org.eclipse.jface.viewers.ViewerCell.setImage(ViewerCell.java:170)
at org.eclipse.jface.viewers.WrappedViewerLabelProvider.update(WrappedViewerLabelProvider.java:166)
at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:145)
at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:932)
at org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeRunnable.run(AbstractTreeViewer.java:102) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.runtime.Platform.run(Platform.java:880) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:1012)
at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:466) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.runtime.Platform.run(Platform.java:880) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:2041)
at org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem(AbstractTreeViewer.java:827)
at org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractTreeViewer.java:802) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:776) at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:634) at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1702) at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1712) at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1712) at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1054) at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1035) at org.jboss.ide.eclipse.freemarker.outline.OutlinePage.update(OutlinePage.java:111) at org.jboss.ide.eclipse.freemarker.editor.Editor.keyReleased(Editor.java:399) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:162) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1040) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036) at org.eclipse.swt.widgets.Widget.wmKeyUp(Widget.java:1753) at org.eclipse.swt.widgets.Control.WM_KEYUP(Control.java:4126) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3819) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4541) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3420) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) 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(EclipseStarter.java:386) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) !ENTRY org.eclipse.ui 4 0 2009-01-27 14:06:20.968 !MESSAGE Error occurred during status handling !STACK 0 org.eclipse.swt.SWTError: No more handles at org.eclipse.swt.SWT.error(SWT.java:3803) at org.eclipse.swt.SWT.error(SWT.java:3695) at org.eclipse.swt.SWT.error(SWT.java:3666) at org.eclipse.swt.widgets.Display.create32bitDIB(Display.java:936) at org.eclipse.swt.widgets.Display.createIcon(Display.java:1019) at org.eclipse.swt.widgets.Decorations.setImages(Decorations.java:981) at org.eclipse.swt.widgets.Decorations.setImages(Decorations.java:1049) at org.eclipse.jface.window.Window.configureShell(Window.java:373) at org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager$InternalDialog.configureShell(WorkbenchStatusDialogManager.java:274)
at org.eclipse.jface.window.Window.createShell(Window.java:502)
at org.eclipse.jface.window.Window.create(Window.java:430)
at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
at org.eclipse.jface.window.Window.open(Window.java:790)
at org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager$InternalDialog.open(WorkbenchStatusDialogManager.java:386) at org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager.addStatusAdapter(WorkbenchStatusDialogManager.java:1123) at org.eclipse.ui.statushandlers.WorkbenchErrorHandler.handle(WorkbenchErrorHandler.java:64) at org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler.handle(IDEWorkbenchErrorHandler.java:91) at org.eclipse.ui.internal.WorkbenchErrorHandlerProxy.handle(WorkbenchErrorHandlerProxy.java:36) at org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:200) at org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:244) at org.eclipse.ui.statushandlers.StatusManager.handle(StatusManager.java:255) at org.eclipse.ui.application.WorkbenchAdvisor.eventLoopException(WorkbenchAdvisor.java:326) at org.eclipse.ui.internal.ExceptionHandler.handleException(ExceptionHandler.java:65) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2386) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) 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(EclipseStarter.java:386) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) !ENTRY org.eclipse.ui 4 0 2009-01-27 14:06:22.890 !MESSAGE Unhandled event loop exception !STACK 0 org.eclipse.swt.SWTError: No more handles at org.eclipse.swt.SWT.error(SWT.java:3803) at org.eclipse.swt.SWT.error(SWT.java:3695) at org.eclipse.swt.SWT.error(SWT.java:3666) at org.eclipse.swt.internal.ImageList.copyWithAlpha(ImageList.java:175) at org.eclipse.swt.internal.ImageList.set(ImageList.java:405) at org.eclipse.swt.internal.ImageList.add(ImageList.java:66) at org.eclipse.swt.widgets.Tree.imageIndex(Tree.java:3618) at org.eclipse.swt.widgets.TreeItem.setImage(TreeItem.java:1685) at org.eclipse.jface.viewers.TreeViewerRow.setImage(TreeViewerRow.java:166) at org.eclipse.jface.viewers.ViewerCell.setImage(ViewerCell.java:170) at org.eclipse.jface.viewers.WrappedViewerLabelProvider.update(WrappedViewerLabelProvider.java:166) at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:145) at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:932) at org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeRunnable.run(AbstractTreeViewer.java:102)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:880)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175) at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(AbstractTreeViewer.java:1012) at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:466)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:880)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175) at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:2041) at org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem(AbstractTreeViewer.java:827) at org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractTreeViewer.java:802)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:776)
at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:634)
at org.eclipse.jface.viewers.AbstractTreeViewer.internalInitializeTree(AbstractTreeViewer.java:1490)
at org.eclipse.jface.viewers.TreeViewer.internalInitializeTree(TreeViewer.java:823)
at org.eclipse.jface.viewers.AbstractTreeViewer$5.run(AbstractTreeViewer.java:1474) at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1365) at org.eclipse.jface.viewers.TreeViewer.preservingSelection(TreeViewer.java:397) at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1328) at org.eclipse.jface.viewers.AbstractTreeViewer.inputChanged(AbstractTreeViewer.java:1467) at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:251) at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1603) at org.jboss.ide.eclipse.freemarker.outline.OutlinePage.update(OutlinePage.java:109) at org.jboss.ide.eclipse.freemarker.editor.Editor.handleCursorPositionChanged(Editor.java:158) at org.eclipse.ui.texteditor.AbstractTextEditor$18.keyPressed(AbstractTextEditor.java:2982)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:155)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1040)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036)
at org.eclipse.swt.widgets.Widget.wmKeyDown(Widget.java:1653)
at org.eclipse.swt.widgets.Control.WM_KEYDOWN(Control.java:4122)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3818)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4541)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2371)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)

etc

• ###### 3. Re: FreeMarker IDE Hangs Consistently

I've done a little reading on Internet, but have not yet looked at Freemarker IDE source. My best guess at this point is that the Freemarker outline view has small resource leak somewhere with respect to the image icons that it uses. It might or might be multi-threading related. It's also possible that the image handle leak is actually somewhere else, but is accelerated when using FreeMarker plugin.

Is there any way to disable the Freemarker outline view? (I can try hiding/removing it from my perspective, but I get the sense it is still executing in the background. I'll try it for a while though.)

• ###### 4. Re: FreeMarker IDE Hangs Consistently

If a view is not shown, not minimized, and otherwise not part of what Eclipse is running, it shouldn't be loaded at all, as Eclipse lazy-loads classes only when they're actually referenced.

-vm should point to java.exe or javaw.exe, not \bin. your Eclipse is running with your system's default VM, which may (coincidentally) be the one you think you've specified.

You can check what Eclipse is actually using in Help > About > Configuration, or explicitly set -vm c:\path\to\java.exe to force a specific one.

As to the "No more handles" SWT problem, I've only ever seen - and solved - that on Linux, which involved this:

# fix for org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
# fix for Failed to invoke suite():org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
ulimit -c unlimited; # set corefile size to unlimited
export JAVA_HIGH_ZIPFDS=500
export LANG=C
.

Here's what Google has to say:

• ###### 5. Re: FreeMarker IDE Hangs Consistently

That is probably a bug in freemarker ide code.

Report it in jira - but even better provide a patch (the old maintainer is not active anymore, so contributions like this will be very welcome)

• ###### 6. Re: FreeMarker IDE Hangs Consistently

Cool. I'll create the report in JIRA. I started looking through the code in SVN. I haven't done Eclipse plugin dev in a long time, and can't take the time to learn/setup a plugin dev environment right now. Maybe in a week or so.

Just looking through code in SVN trunk though, I doesn't look like the label images used in the tree are ever being disposed. The ImageManager creates the image here:

public static Image getImage(String filename) {
if (null == filename) return null;
ImageDescriptor temp = getImageDescriptor(filename);
if(null!=temp) {
return temp.createImage();
} else {
return null;
}
}

They get used in OutlineLabelProvider here:

public Image getImage(Object anElement) {
if (null == anElement)
return null;
if (anElement instanceof Item) {
return ImageManager.getImage(((Item) anElement).getTreeImage());
}
else {
return null;
}
}

And from what I can see, they are never disposed. My guess is that the outline labels are reconstructed quite often, and so more and more images get created but never disposed.

Assuming SWT images are immutable and can be reused, the fix could be as simple as modifying OutlineLabelProvider to cache the images in a map by filename. Then, making sure they are reused on every call to the provider. (Should also dispose them when the OutlineLabelProvider is disposed, but if the images are being reused, it probably doesn't matter much.)

• ###### 7. Re: FreeMarker IDE Hangs Consistently

JIRA issue created here: https://jira.jboss.org/jira/browse/JBIDE-3661

I made an assumption that the cause actually is non-disposed images. I'll try to verify/fix myself in a few weeks if no one gets to it before then.