Server consistently crashes after ~1 hour with heap space error

Hi all,

As stated in the title, I am consistently crashing on my server due to an out of memory error. I have tried to run a few test cases to figure out the problem and these have been my results so far:

Server will crash within +/- 1 minute after 60 minutes of runtime.

Doesn’t appear to be caused by client/server messages back and forth, crash is consistent whether 6 clients are connected and communicating thoroughly or if the server has had no clients connect the entire session.

Run time before crash is directly based on how much memory is allocated…if I double the memory, ~double the runtime before a crash, but that doesn’t seem like a solution and I feel like there’s some GC that can/should be getting done.

Details of error are as follows:

java.lang.OutOfMemoryError: Java heap space
at com.jme3.renderer.queue.GeometryList.add(GeometryList.java:114)
at com.jme3.renderer.queue.RenderQueue.addToQueue(RenderQueue.java:282)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:674)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:665)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:665)
at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:640)
at com.jme3.bullet.debug.BulletDebugAppState.render(BulletDebugAppState.java:132)
at com.jme3.app.state.AppStateManager.render(AppStateManager.java:300)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:251)
at com.jme3.system.NullContext.run(NullContext.java:130)
at java.lang.Thread.run(Thread.java:744)

I don’t see anything in the error referencing the main class specifically (ServerMain in this instance). I am a bit new to jmonkey and java in general, but am I correct in assuming the server is doing some sort of periodic update on all geometries in the scene, and this just happens to be the Nth iteration where a limit is reached?

Any thoughts/advice towards helping me understand the problem is greatly appreciated! Thanks!

The reason it happens is because the physics debug is being rendered … and because the queues are not flushed when using headless mode, it will eventually overfill and cause out of memory error.
The solution is to disable physics debug rendering.

1 Like

Thanks for the quick response!
Would I do that from the bulletAppState, or more specifically the PhysicsSpace? I see debug methods inside each of those, but neither of them specifically mention rendering.

Somewhere in the code you’re calling BulletAppState.setDebugEnabled(true).

You’re right. Found it, removed it…works like a charm!

Thanks so much for the help. Great first impression of the forum as well.