What can be the reason for the freezing java app (a game made by JME3)?

what can be the reason for the freezing java app (a game made by JME3)?

my game some times crashed and froze. I don’t know why.
maybe because of processing a large navmesh (but every time it works well and some times froze)?
or because of the need for more memory?

1 Like

Could be a hundred different things… bad drivers, out of memory…

We’d need to see the error to be able to answer.

2 Likes

Can you provide stack-trace of a crash? Are there any OOM errors?

If its Memory related, the HUD OpenGL stats are very useful for figuring out if the code for your scenes is inefficient.

2 Likes

Is it a crash or a freeze? Those are technically different things.

In the case that it is freezing without any errors or stack trace, then you may have accidentally put an unbreakable infinite loop somewhere in your code.

2 Likes

If there’s no stack trace or crash log, then use the Java debugger to determine what each thread is doing. jdb - The Java Debugger

3 Likes

If run from the command line you can also hit ctrl-break and it will dump all of the thread stack traces to console (and show you any deadlocks).

5 Likes

it is a frozen state and no error prints. everything froze and just continue playing sound.

when it froze I pressed ctrl+pause/break key on the keyboard but nothing happened.

1 Like

Sounds like an infinite loop. I don’t know which IDE you use, but in Eclipse you can run your game in debug mode. When it freezes, you can pause each thread on by another in the debug view. Then you will be able to see where your threads are in the code.

2 Likes

I used Netbeans Ide (jme SDK 3.2 with OpenJDK 1.8_212b04).
nothing prints. nothing showed. I used debugger for Netbeans but I can’t find the problem.

1 Like

Please provide further details. Every single point is important for us. It could be anything… a deadlock, an infinite loop, a GPU driver crash, a GPU device failure…

Use VisualVM or jProfiler to analyze your threads when it freezes. Or can’t you see anything because your screen is black and you need to reset your PC? A frozen/black screen, but the sound is still playing is a sign of a GPU/PSU hardware failure.

2 Likes

no, the last frame of the scene is showing there, the mouse pointer can move but not work in-game nothing cant select, keyboard not working. just plays sound. and CPU usage increase fan speed.
I tried it on another computer, os, and different hardware.

1 Like

This only works if you run from the command line. Then when your app locks up you have to switch to the command line window and hit ctrl-break.

From your other posts, it does sound like you have an infinite loop somewhere in your code where it just runs and runs in a circle using 100% CPU. So another approach would be to comment things out to see if things start working again.

2 Likes

I pressed ctrl+break in cmd when it froze. nothing happened.

1 Like

Wow, for all the years I have been programming Java, I never knew this! Just tested on one of my apps, this works great. I will have to add this to my mental tool box.

2 Likes

Yeah, it’s a cool trick. Finding deadlocks prior to that was an interesting job.

2 Likes

Getting thread/memory dump is also part of jVisualVM. Highly recommend it.

2 Likes

Well, you have to run your app from the command line and press Ctrl+Break on the same command line window for it to work.

2 Likes

I did it but is not working.

1 Like

Just to be sure you’re doing it right, does it work when the app is not locked up?

…this is a pretty fundamental thing. So it should always work.

2 Likes

I tried with another java program, it’s not working at all.

java -version
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
1 Like