I have developed a bunch of menus. Each menu is a single game state, which contains a jme desktop.

During the start of the game i'm initializing every state and than i'm just activating and deactivating them depending on user inputs.

But after a certain time I get the following Exception:

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: unable to create new native thread

at java.lang.Thread.start0(Native Method)

at java.lang.Thread.start(

at java.awt.EventQueue.initDispatchThread(


When I'm observing the game in the task manager, i can see, that the java vm allocates one or two mb every second until I get the exception…

What could be the mistake?

I thought, that i'm allocation some memory during every update method executing somewhere… but this is not the case…

  :? :? :?

are you using eclipse i think you should try increasing the maximum java heap size in the configuration file in the same folder as eclipse

heres a link.

I already hava 1g heap. It takes normally 2 minutes before i get the error

I guess you create new objects every update cycle, which can't get garbage collected.

Check your update loop again, maybe the debugger or a profiler can gve you hints whats wrong.

It is possible to have memory leaks in Java so be careful of how you create new objects and if you somehow keep a reference to them then you shouldn't.

2MB per second is a lot :open_mouth:


there is nothing in the update methods, which might allocate memory constantly - a least not in the update methods of the gamestates which activated when the crash happen…

Can it be that it is because I m initializing 20 gamestates containing jmedesktops at beginning of the game.

They need a lot of memory.

I would prefer to create the gamestates with the jme desktops only when they should be displayed to the user.

But I cannot create them in the actionlistener, because then I get a "not in swing thead exception"…

I'm desperate  :? :? :? :? :? :? :? :?

What could I do?

I have experienced a similar problem.

I'm sorry to give you the answer for this.

Many JmeDesktop actions consume heap memory.

Above all things, When JTextField has focus (in other words, caret is blinking) heap memory is constantly increasing.

You can check it by running TestJmeDesktop.

Becase of the problem, now I am changing my project UI to BUI.

You can use FengGUI, BUI or other GUI.

hehe, oh yeah it uses like 1 MB every 20 seconds. I think it has been mentioned before :).

So if anyone can profile it and provide a fix that would be great.

I try to look into it when i have some spare time.

JMEDesktop(Swing) is extensible, flexible and supports unicode.

But it has memory problem (until now)

Moreover, what is more important is speed.

Based on my experience,

When building commercial quality application, JMEDesktop is not applicable.

well i tried to profile it and actually now i can't see anything problematic in TestJMEDesktop.

The garbage collector seems to do his job well.

Thx for your help…

a single jmedesktop is not the porblem. also a few work fine… but i think it is the mass of desktops…

i will try now gbui… but i connot get it running…

i checked it out from the svn, but there are errors in it form the very beginning…

:? :? :?

why is that? is it my mistake???

Until now it's jme version1 compatible