about "java.lang.outOfMemory"

hi everybody:

    I am developing a JOGL application, mixing 2D & 3D using the GLJPanel component to render. For the project requirement, the application need to create a lots of instance of GLJPanel.  And this GLJPanel object is actually rewrite by myselft, such following code:

class MyPanel extends GLJPanel
{
public MyPanel() {
}
public void paintComponenet(Graphics g) {
super.paintComponent(g);
// do some special
}
}

Because I need to render special 2D things. the problem is when I invoke "new MyPanel()"many times later, there will throw a “java.lang.OutOfMemory” error. Does someone known this issue? Thanks!

You may try to increase the Java heap size of your app. By default the maximum heap space is 128mb for client jvm, so it might be too little if you use lot of GLJPanels.
To increase it, you must run your application using “java -Xmx***m” where *** is the maximum heap size in megabyte you want to use.

Thank you gibe!

You are very good personal, I think this problem can be solved, but another question, if I am using “Java Web Start” to launch this application, how to set the VM parameter?

I’ve never used java web start, sorry. Maybe someone else could give you an int on how to set a jvm option when using java web start.

In webstart, you set those in the .jnlp file:
http://java.sun.com/docs/books/tutorial/deployment/webstart/deploying.html (look for ‘max-heap-size’)

While adjusting the heap size might work, you should evaluate if you are not doing something wrong, if you need “many” GLJPanel instances. What is the purpose of your app and why does it need so many different GLJPanel instances? Maybe you would be better of only exchanging the 2D components and use a single GLJPanel.