eclipse-platform / eclipse.platform.ui

Eclipse Platform
https://projects.eclipse.org/projects/eclipse.platform
Eclipse Public License 2.0
81 stars 188 forks source link

"No more handles" - after editing many MANIFEST.MF #2304

Open jukzi opened 1 month ago

jukzi commented 1 month ago

image image

I have a Heapdump - how do i figure out what leaked? image

akurtakov commented 1 month ago

No more handles means the OS is out of resources for more widgets. Most likely an SWT widget is recreated over and over without unused ones being disposed. You may want to try Sleak (https://github.com/eclipse-platform/eclipse.platform.swt/blob/master/bundles/org.eclipse.swt.tools.spies/src/org/eclipse/swt/tools/views/SleakView.java ) and there is an old article on using it https://www.eclipse.org/articles/swt-design-2/sleak.htm . I haven't used it in years so I'm not sure of current state of the tool. Long story short - it's most likely a missing dispose() somewhere.

mickaelistria commented 1 month ago

If you can monitor the running application on your machine, using Sleak can help. Here there are 12k resource trackers, which means that there are 12k resources; tracker element and their "nest" object will show which objects are locking the resources/missing the dispose().

jukzi commented 1 month ago

Why would i have a thousend fonts in my heap? Beside that i don't get where i can see useful information in the dump: image

If anybody wants to look: https://securetransfer.ssi-schaefer.com/webdownload?deliveryUuid=b2398f9c-3c49-4310-a8e5-cf39f47f21bc

BTW the Exception was:

org.eclipse.swt.SWTError: No more handles
    at org.eclipse.swt.SWT.error(SWT.java:4948)
    at org.eclipse.swt.SWT.error(SWT.java:4837)
    at org.eclipse.swt.SWT.error(SWT.java:4808)
    at org.eclipse.swt.widgets.Widget.error(Widget.java:500)
    at org.eclipse.swt.widgets.Control.createHandle(Control.java:675)
    at org.eclipse.swt.widgets.Scrollable.createHandle(Scrollable.java:146)
    at org.eclipse.swt.widgets.Composite.createHandle(Composite.java:300)
    at org.eclipse.swt.widgets.Control.createWidget(Control.java:701)
    at org.eclipse.swt.widgets.Scrollable.createWidget(Scrollable.java:161)
    at org.eclipse.swt.widgets.Control.<init>(Control.java:121)
    at org.eclipse.swt.widgets.Scrollable.<init>(Scrollable.java:85)
    at org.eclipse.swt.widgets.Composite.<init>(Composite.java:103)
    at org.eclipse.swt.widgets.Canvas.<init>(Canvas.java:81)
    at org.eclipse.jface.text.source.AnnotationRulerColumn$3.<init>(AnnotationRulerColumn.java:338)
    at org.eclipse.jface.text.source.AnnotationRulerColumn.createCanvas(AnnotationRulerColumn.java:338)
    at org.eclipse.jface.text.source.AnnotationRulerColumn.createControl(AnnotationRulerColumn.java:256)
    at org.eclipse.ui.internal.texteditor.AnnotationColumn.createControl(AnnotationColumn.java:70)
    at org.eclipse.jface.text.source.CompositeRuler.addDecorator(CompositeRuler.java:544)
    at org.eclipse.ui.texteditor.AbstractTextEditor$ColumnSupport$1.run(AbstractTextEditor.java:1632)
jukzi commented 1 month ago

Would be better if the excpetion would just log a histogram of the resource stacktraces.

HeikoKlare commented 1 month ago

I would rather expect the reason to be in controls, not in resources. 12k resource trackers does not seem to be too many. In an ordinary SDK product, I have > 30k resource trackers. Note that not each resource tracker means that there is a handle behind it. E.g., there are many font instances sharing the same handle. Usually, on Windows you have only few font handles but many Font instances (e.g., due to this implementation). TextLayouts (which are by far most of the resources in the heap dump) don't even have a handle on their own (do they?) but may only reference other elements that then use handles.

The task manager screenshot indicates that you are running out of user object handles. There are 9982 with 10000 being the limit on Windows. Maybe the reason is related to the number of controls? E.g. there seem to be quite some TreeItem instances: image

jukzi commented 1 month ago

such fonts would have ignoreMe=true - but they don't have https://github.com/eclipse-platform/eclipse.platform.swt/blob/02e20d69dcddf3567979ebb33ef73f43e3d5fd4b/bundles/org.eclipse.swt/Eclipse%20SWT/common/org/eclipse/swt/graphics/Resource.java#L156

HeikoKlare commented 1 month ago

Okay, I see that there are several fonts without that flag. They seem to be created in StyledTextRenderer for the purpose of styled text rendering. image

Still, they only make up few of the font instances. But it could make sense if some StyledText / StyledTextRenderer and with them the fonts are leaked (or at least, not cleaned up already). Did you have many (other) text editors open when or before creating the heap dump? Or was it "only" the Manifest editors? There are 357 StyledText instances and an according number of renderers.

image

jukzi commented 1 month ago

I don't remember everything i did but for sure i used eclipse for some hours for various things.

-- may relate to I20240923 failed some unit tests with "No more handles" too: https://download.eclipse.org/eclipse/downloads/drops4/I20240923-0040/testresults/html/org.eclipse.ui.tests_ep434I-unit-win32-java17_win32.win32.x86_64_17.html