[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Maximum number of objects when using Linux/GTK

I'm not sure why you would need that many objects/widgets. If you're using 
images, fonts or cursors, cache them and re-use them and dispose the ones 
you don't need. Same goes for other widgets. That'll leave you with more 
handles to play with.

In any case, as far as I can recall it's an OS limitation and there's 
nothing much you can do to increase it.

Emil

"hortiz" <helene.chagnot@xxxxxxxxx> wrote in message 
news:e5540381544d41f60e955c31213d06da$1@xxxxxxxxxxxxxxxxxx
> Hi,
>
> When creating a large amount of widgets in my SWT application, an error 
> occurs and the following message is displayed:
>
> (SWT:28652): GLib-GObject-CRITICAL **: g_closure_ref: assertion 
> `closure->ref_count < CLOSURE_MAX_REF_COUNT' failed
> #
> # An unexpected error has been detected by HotSpot Virtual Machine:
> #
> #  SIGSEGV (0xb) at pc=0xb0dbc72e, pid=28652, tid=3085366976
> #
> # Java VM: Java HotSpot(TM) Client VM (1.5.0_10-b03 mixed mode, sharing)
> # Problematic frame:
> # C  [libgobject-2.0.so.0+0x1972e]
> #
> # An error report file with more information is saved as 
> hs_err_pid28652.log
> #
> # If you would like to submit a bug report, please visit:
> #   http://java.sun.com/webapps/bugreport/crash.js
>
> I wrote this snippet to know if it was a problem concerning the huge 
> number of created widgets:
>
> package test;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.widgets.Text;
>
> public class MaximumNumberOfTextWidgets {
>
> public static void main(String[] args) {
>
> int max = 100000;
>
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setLayout(new GridLayout());
>
> for (int i = 0; i < max; i++) {
> Text text = new Text(shell, SWT.NONE);
> text.setText(i+"");
> System.out.println(i);
> }
>
> shell.pack ();
> shell.open();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
> The same error occurs when i = 32763, which is really close to 2 power 15 
> (32768). Does this mean that the number of widgets is limited to this 
> value ? Do we have the possibility to increase this value ?
>
> Thanks !
> Helene
>
>
>
>
>