JME doesnot work when starting java with -Xms40m -Xmx1024m (sometimes)

The following sample shows empty window on my machine, when launched with -Xms40m -Xmx1024m (-Xms40m -Xmx512m works fine). Our production application also suffers the same problem: depending on -Xms, -Xmx parameters it sometimes renders what it have to while sometimes not.



[java]

package com.excelsior.lms.proto.jme;



import java.util.HashMap;



import org.eclipse.swt.SWT;

import org.eclipse.swt.layout.FillLayout;

import org.eclipse.swt.widgets.Composite;

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt.widgets.Shell;



import com.jme.bounding.BoundingBox;

import com.jme.input.KeyInput;

import com.jme.math.Quaternion;

import com.jme.math.Vector3f;

import com.jme.scene.shape.Capsule;

import com.jme.scene.state.CullState;

import com.jme.system.DisplaySystem;

import com.jme.system.canvas.SimpleCanvasImpl;

import com.jme.system.lwjgl.LWJGLSystemProvider;

import com.jmex.swt.input.SWTKeyInput;

import com.jmex.swt.input.SWTMouseInput;

import com.jmex.swt.lwjgl.LWJGLSWTCanvas;

import com.jmex.swt.lwjgl.LWJGLSWTCanvasConstructor;

import com.jmex.swt.lwjgl.LWJGLSWTConstants;



public class SwtRotatingCapsule {



static int width = 640, height = 480;



public static void main(String[] args) {

final Display display = new Display();

Shell shell = new Shell(display);

shell.setLayout(new FillLayout());

Composite comp = new Composite(shell, SWT.NONE);

comp.setLayout(new FillLayout());



DisplaySystem ds = DisplaySystem.getDisplaySystem(LWJGLSystemProvider.LWJGL_SYSTEM_IDENTIFIER);

ds.registerCanvasConstructor(“SWT”, LWJGLSWTCanvasConstructor.class);



HashMap<String, Object> props = new HashMap<String, Object>();

props.put(LWJGLSWTConstants.PARENT, comp);

props.put(LWJGLSWTConstants.STYLE, SWT.NONE);

props.put(LWJGLSWTConstants.DEPTH_BITS, 8);

final LWJGLSWTCanvas canvas = (LWJGLSWTCanvas) ds.createCanvas(width, height, “SWT”, props);

canvas.setUpdateInput(true);

canvas.setTargetRate(60);



KeyInput.setProvider(SWTKeyInput.class.getCanonicalName());

canvas.addKeyListener((SWTKeyInput) KeyInput.get());



SWTMouseInput.setup(canvas, true);



// Important! Here is where we add the guts to the panel:

MyImplementor impl = new MyImplementor(width, height);

canvas.setImplementor(impl);



shell.setText(“SWT/JME Example”);

shell.setSize(width, height);

shell.open();



canvas.init();

canvas.render();



while (!shell.isDisposed()) {

if (!display.readAndDispatch())

display.sleep();

}

display.dispose();

}



private static class MyImplementor extends SimpleCanvasImpl{



private Quaternion rotQuat = new Quaternion();

private float angle = 0;

private Vector3f axis = new Vector3f(1, 1, 0).normalizeLocal();

private Capsule t;



protected MyImplementor(int width, int height) {

super(width, height);

}



@Override

public void simpleSetup() {

t = new Capsule(“Capsule”, 40, 32, 16, 4, 10);

t.setModelBound(new BoundingBox());

t.updateModelBound();

t.setRandomColors();



CullState cs = getRenderer().createCullState();

cs.setCullFace(CullState.Face.Back);

rootNode.setRenderState(cs);

rootNode.attachChild(t);

}



@Override

public void simpleUpdate() {

if (timer.getTimePerFrame() < 1) {

angle = angle + (timer.getTimePerFrame() * 1);

if (angle > 360) {

angle = 0;

}

}



rotQuat.fromAngleNormalAxis(angle, axis);

t.setLocalRotation(rotQuat);

}

}

}

[/java]



Any ideas?



Thanks,

Sergey

Sorry for code typo, corrected version is below:



[java]package com.excelsior.lms.proto.jme;



import java.util.HashMap;



import org.eclipse.swt.SWT;

import org.eclipse.swt.layout.FillLayout;

import org.eclipse.swt.widgets.Composite;

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt.widgets.Shell;



import com.jme.bounding.BoundingBox;

import com.jme.input.KeyInput;

import com.jme.math.Quaternion;

import com.jme.math.Vector3f;

import com.jme.scene.shape.Capsule;

import com.jme.scene.state.CullState;

import com.jme.system.DisplaySystem;

import com.jme.system.canvas.SimpleCanvasImpl;

import com.jme.system.lwjgl.LWJGLSystemProvider;

import com.jmex.swt.input.SWTKeyInput;

import com.jmex.swt.input.SWTMouseInput;

import com.jmex.swt.lwjgl.LWJGLSWTCanvas;

import com.jmex.swt.lwjgl.LWJGLSWTCanvasConstructor;

import com.jmex.swt.lwjgl.LWJGLSWTConstants;



public class SwtRotatingCapsule {



static int width = 640, height = 480;



public static void main(String[] args) {

final Display display = new Display();

Shell shell = new Shell(display);

shell.setLayout(new FillLayout());

Composite comp = new Composite(shell, SWT.NONE);

comp.setLayout(new FillLayout());



DisplaySystem ds = DisplaySystem.getDisplaySystem(LWJGLSystemProvider.LWJGL_SYSTEM_IDENTIFIER);

ds.registerCanvasConstructor(“SWT”, LWJGLSWTCanvasConstructor.class);



HashMap<String, Object> props = new HashMap<String, Object>();

props.put(LWJGLSWTConstants.PARENT, comp);

props.put(LWJGLSWTConstants.STYLE, SWT.NONE);

props.put(LWJGLSWTConstants.DEPTH_BITS, 8 );

final LWJGLSWTCanvas canvas = (LWJGLSWTCanvas) ds.createCanvas(width, height, “SWT”, props);

canvas.setUpdateInput(true);

canvas.setTargetRate(60);



KeyInput.setProvider(SWTKeyInput.class.getCanonicalName());

canvas.addKeyListener((SWTKeyInput) KeyInput.get());



SWTMouseInput.setup(canvas, true);



// Important! Here is where we add the guts to the panel:

MyImplementor impl = new MyImplementor(width, height);

canvas.setImplementor(impl);



shell.setText(“SWT/JME Example”);

shell.setSize(width, height);

shell.open();



canvas.init();

canvas.render();



while (!shell.isDisposed()) {

if (!display.readAndDispatch())

display.sleep();

}

display.dispose();

}



private static class MyImplementor extends SimpleCanvasImpl{



private Quaternion rotQuat = new Quaternion();

private float angle = 0;

private Vector3f axis = new Vector3f(1, 1, 0).normalizeLocal();

private Capsule t;



protected MyImplementor(int width, int height) {

super(width, height);

}



@Override

public void simpleSetup() {

t = new Capsule(“Capsule”, 40, 32, 16, 4, 10);

t.setModelBound(new BoundingBox());

t.updateModelBound();

t.setRandomColors();



CullState cs = getRenderer().createCullState();

cs.setCullFace(CullState.Face.Back);

rootNode.setRenderState(cs);

rootNode.attachChild(t);

}



@Override

public void simpleUpdate() {

if (timer.getTimePerFrame() < 1) {

angle = angle + (timer.getTimePerFrame() * 1);

if (angle > 360) {

angle = 0;

}

}



rotQuat.fromAngleNormalAxis(angle, axis);

t.setLocalRotation(rotQuat);

}

}

}

[/java]

It might have something to do with SWT, since I’ve never heard of jME being effected by those parameters (apart from preventing java heap errors).

Momoko_Fan said:
It might have something to do with SWT, since I've never heard of jME being effected by those parameters (apart from preventing java heap errors).


I have cooked an example and some of my colleagues launched it. The following subsystem was used:
[java]
DisplaySystem display = DisplaySystem
.getDisplaySystem(LWJGLSystemProvider.LWJGL_SYSTEM_IDENTIFIER);
display.registerCanvasConstructor("AWT", LWJGLAWTCanvasConstructor.class);
[/java]

In this example, the following jvm params was used: -Xms40m -Xmx900m. This problem also appeared for some of the WinXp, Windows Vista and Windows 7 workstations (however, for some it doesnot appear).

And besides, I was able to reproduce this problem on jmetest.util.JMESwingTest, when the latter was launched with -Xms40m -Xmx1024m from Eclipse. It simply doesnot render anything.

So I suppose the problem is definitely there... Can you please try launching jmetest.util.JMESwingTest with -Xms40m -Xmx1024m parameters on your workstation?