Community
Participate
Working Groups
I commonly die a horrible death because of the following SWT error. (no more handles) This causes other programs (like Notes) to look weird when trying to draw icons, etc. In a common day I have to reboot my machine 3 or 4 times to "reclaim" all lost resources. org.eclipse.swt.SWTError: No more handles at java.lang.Error.<init>(Error.java:52) at org.eclipse.swt.SWTError.<init>(SWTError.java:45) at org.eclipse.swt.SWTError.<init>(SWTError.java:34) at org.eclipse.swt.SWT.error(SWT.java:1798) at org.eclipse.swt.SWT.error(SWT.java:1707) at org.eclipse.swt.graphics.Image.init(Image.java(Compiled Code)) at org.eclipse.swt.graphics.Image.<init>(Image.java(Compiled Code)) at org.eclipse.jface.resource.ImageDescriptor.createImage(ImageDescriptor.java:106) at org.eclipse.jface.resource.ImageDescriptor.createImage(ImageDescriptor.java:77) at org.eclipse.jface.action.ActionContributionItem$ImageCache.getImage(ActionContributionItem.java:90) at org.eclipse.jface.action.ActionContributionItem.updateImages(ActionContributionItem.java:586) at org.eclipse.jface.action.ActionContributionItem.update(ActionContributionItem.java:493) at org.eclipse.jface.action.ActionContributionItem.fill(ActionContributionItem.java:249) at org.eclipse.jface.action.MenuManager.update(MenuManager.java:434) at org.eclipse.jface.action.MenuManager.update(MenuManager.java:364) at org.eclipse.ui.internal.ShortcutMenu.updateMenu(ShortcutMenu.java:119) at org.eclipse.ui.internal.ShortcutMenu.pageActivated(ShortcutMenu.java:67) at org.eclipse.ui.internal.PageListenerList$1.run(PageListenerList.java:38) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:606) at org.eclipse.core.runtime.Platform.run(Platform.java:388) at org.eclipse.ui.internal.PageListenerList.firePageActivated(PageListenerList.java:36) at org.eclipse.ui.internal.WorkbenchWindow.firePageActivated(WorkbenchWindow.java:428) at org.eclipse.ui.internal.WorkbenchWindow.access$10(WorkbenchWindow.java:427) at org.eclipse.ui.internal.WorkbenchWindow$5.run(WorkbenchWindow.java:840) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:81) at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:827) at org.eclipse.ui.internal.SetPageAction.run(SetPageAction.java:41) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:406) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:360) at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:351) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:45) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java(Compiled Code)) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:643) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java(Compiled Code)) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java(Compiled Code)) at org.eclipse.ui.internal.Workbench.run(Workbench.java:610) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:850) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:280) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:67) at org.eclipse.core.launcher.Main.run(Main.java:299) at org.eclipse.core.launcher.UIMain.main(UIMain.java:43) NOTES: NE (06/11/01 10:01:27 AM) See 1GE8K2O: ITPUI:WIN98 - GDI usage stats for opening perspectives ARCH (7/11/01 11:11:01 AM) Fix in 1.0 NE (07/19/01 2:31:16 PM) ImageDescriptor.createImage() is spec'ed to always return a new image, so it can't return null, and can't return a shared image (i.e. the missing image). And it can't be changed to catch the out-of-handles SWTError and create a new missing image, since it's out of handles. Only alternative is to change all cases to use ImageDescriptor.createImage(boolean), and handle the null case and SWTError. SWTError states: SWTErrors should not occur in typical programs, although "high reliability" applications should still catch them. Could change ImageDescriptor.createImage(boolean) to catch the SWTError for the out-of-handles condition (SWTError has a code), and have it return null. So this would avoid the need for all users to catch it. Of course, it would be better not to run out of handles in the first place, but we can't control this in general. We can only minimize the number of images we create. KH (8/1/2001 8:37:17 AM) Your proposal makes sense. Hold off making these changes until the SWT team fixes their part of this problem. They are going to be releasing changes that significantly reduce the number of images that need to be created. NE (8/8/2001 3:19:49 PM) Try changing ActionContributionItem to not create extra images on Win98: disabled and hot image. Use the hot image as the regular one.
PRODUCT VERSION: 0.106 JRE on Win98
*** Bug 2147 has been marked as a duplicate of this bug. ***
Shouldn't this be throwing SWTException instead of SWTError? Is it really a fatal SWT error if it can't allocate an image? Eduardo, can you please investigate whether the exception can be handled better.
Unfortunately, by the time you have run out of handles, your application is potentially in an unstable situation. For example, any o/s mechanisms which rely on painting images may fail in ways that *they* weren't expecting to deal with, causing GPs or similar.
*** This bug has been marked as a duplicate of 2859 ***