subtle blips while playing java games?

when playing java games i notice that there are blips in gameplay, sometimes subtle, sometimes not so subtle, that make the gameplay not comepletely smooth. what is causing this?

Could be lots of issues. My guess would be gratuitous garbage collection.

Very briefly, it is the same reason why any software behaves badly: a bad implementation. These problems are not inherent to Java.

is there a way to fix that? like a way to turn off GC?

No, you can’t (and shouldn’t) turn off the GC. There are several command line options to tune it: http://www.petefreitag.com/articles/gctuning/. My best guess would be, that starting the JVM with -Xincgc could reduce the blips.

GC never causes blips of itself - it’s just too fast unless you try especially hard to make a lot of garbage. It’s likely to be that pesky thread priority bug and AWT-related finalizer issue again. What JVM is this?

Cas :slight_smile:

well im not so sure about what JVM, i use, so i guess i use the default Sun JVM.

about GC, i did a little research, and i learned that java uses mark sweep GC. i also learned that the other language that i like, python, uses a different kind, reference counting. do all GCing languages have the same (possible) blip problem as java? or is it only languages that use the same GC method as Java?

To figure out the JVM version, run the java command with the -version option:

java -version

Also, you can supply the following options (if you’re running the Sun HotSpot JVM) if you want to correlate GC operations to the blips you are seeing:

java -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps

Are you calling Thread.sleep in your main loop? You can’t count on Thread.sleep to only sleep for the amount of time you specify. The millisecond timer has poor granularity on Windows machines (10 milliseconds is the best I’ve seen), and Thread.sleep sleeps AT LEAST that amount of time. It could sleep for more.

I eliminated Thread.sleep in my main loop and replaced it with Thread.yield, and similar blips that my program had disappeared. I thought it was a whole variety of issues, but removing Thread.sleep fixed it.

I also thought my problems were caused by GC at one time, but rewriting my code so that hardly any garbage was created did no good.

Hi,

Of course there are lots of things it could be, but most likely it is because the frame rate of the game is not locked to the refresh rate of the screen. Only some java OGL games do this, the core java API has no way to do this yet. There is a bug on it, I’ll find it soon.

Keith

define “blip”.

One common source of glitches is thread contention, running your refresh while other threads
are busy changing the underlying data structures.

Another common condition is painting your screen in several steps, where occasionally the
timing allows you to see an intermediate step, which is normally repainted before you can see it.