Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-dev] No more handles in SWT, can this number be configured?

Hi Wim,

They do, you can easily verify by running  the following snippets on Windows:

--------
/*
 * Slight modified standard snippet
 *
 * For a list of all SWT example snippets see
 * http://www.eclipse.org/swt/snippets/
 */
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class Snippet37 {

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Snippet 37");
shell.setLayout(new FillLayout());

for (int i = 0; i < 20000; i++) {
new Label(shell, SWT.NONE);
}
shell.setSize(200, 200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}

----

Run it and get:

Exception in thread "main" org.eclipse.swt.SWTError: No more handles
at org.eclipse.swt.SWT.error(SWT.java:4919)
at org.eclipse.swt.SWT.error(SWT.java:4808)
at org.eclipse.swt.SWT.error(SWT.java:4779)
at org.eclipse.swt.widgets.Widget.error(Widget.java:438)
at org.eclipse.swt.widgets.Control.createHandle(Control.java:718)
at org.eclipse.swt.widgets.Label.createHandle(Label.java:188)
at org.eclipse.swt.widgets.Control.createWidget(Control.java:746)
at org.eclipse.swt.widgets.Control.<init>(Control.java:116)
at org.eclipse.swt.widgets.Label.<init>(Label.java:106)
at aaa.handlers.Snippet37.main(Snippet37.java:22)

Best regards, Lars

On Fri, Apr 16, 2021 at 2:12 PM Wim Jongman <wim.jongman@xxxxxxxxx> wrote:
>
> I am surprised if non-disposable objects take a system handle.
>
> Cheers,
>
> Wim
>
> On Fri, Apr 16, 2021 at 11:47 AM Lars Vogel <lars.vogel@xxxxxxxxxxx> wrote:
>>
>> What everybody.
>>
>> Unfortunately, it looks like deviceData.objects also "only" tracks the
>> disposable objects, not all objects. For example, if I create 1000
>> Labels and enable tracking these are not included in the count.
>>
>> ----------
>> DeviceData deviceData = widget.getDisplay().getDeviceData();
>> int length = deviceData.objects.length;
>> System.out.println(length);
>> ------------
>>
>> Best regards, Lars
>>
>>
>>
>> On Thu, Apr 15, 2021 at 10:36 PM Jonah Graham <jonah@xxxxxxxxxxxxxxxx> wrote:
>> >
>> >
>> > ~~~
>> > Jonah Graham
>> > Kichwa Coders
>> > www.kichwacoders.com
>> >
>> >
>> > On Thu, 15 Apr 2021 at 15:27, Alex Blewitt <alex.blewitt@xxxxxxxxx> wrote:
>> >>
>> >> On 15 Apr 2021, at 19:31, Wim Jongman <wim.jongman@xxxxxxxxx> wrote:
>> >>
>> >> On Thu, Apr 15, 2021 at 6:09 PM Lars Vogel <lars.vogel@xxxxxxxxxxx> wrote:
>> >>>
>> >>>
>> >>>
>> >>> Would be nice to be able to ask SWT at runtime for the currently
>> >>> allocated handlers so that we can be a bit more reactive to the
>> >>> currently available handlers instead of just using a hard-tab limit.
>> >>
>> >>
>> >> Display.getDeviceData().objects?
>> >> https://help.eclipse.org/2021-03/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Findex.html
>> >>
>> >>
>> >> This only returns a value if tracking has been enabled, and it adds a significant overhead. It’s useful for tracking down some leaks but wouldn’t recommend using it for an application in real use. In any case, the set of objects here don’t necessarily tell you how many handles are being used by the OS, although to a first-order approximation you could guess on a 1-1 mapping.
>> >
>> >
>> > https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/163437 adds DeviceData#getAllocatedResourceCount which returns number of allocated devices without the overhead of objects, nor needing tracking to be on.
>> >
>> > HTH,
>> > Jonah
>> >
>> >
>> >>
>> >>
>> >> Alex
>> >> _______________________________________________
>> >> eclipse-dev mailing list
>> >> eclipse-dev@xxxxxxxxxxx
>> >> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/eclipse-dev
>> >
>> > _______________________________________________
>> > eclipse-dev mailing list
>> > eclipse-dev@xxxxxxxxxxx
>> > To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/eclipse-dev
>>
>>
>>
>> --
>> Eclipse Platform project co-lead
>> CEO vogella GmbH
>>
>> Haindaalwisch 17a, 22395 Hamburg
>> Amtsgericht Hamburg: HRB 127058
>> Geschäftsführer: Lars Vogel, Jennifer Nerlich de Vogel
>> USt-IdNr.: DE284122352
>> Fax (040) 5247 6322, Email: lars.vogel@xxxxxxxxxxx, Web: http://www.vogella.com
>> _______________________________________________
>> eclipse-dev mailing list
>> eclipse-dev@xxxxxxxxxxx
>> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/eclipse-dev
>
> _______________________________________________
> eclipse-dev mailing list
> eclipse-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/eclipse-dev



-- 
Eclipse Platform project co-lead
CEO vogella GmbH

Haindaalwisch 17a, 22395 Hamburg
Amtsgericht Hamburg: HRB 127058
Geschäftsführer: Lars Vogel, Jennifer Nerlich de Vogel
USt-IdNr.: DE284122352
Fax (040) 5247 6322, Email: lars.vogel@xxxxxxxxxxx, Web: http://www.vogella.com


Back to the top