Help!! Native Errors

Hi can someone help me?

I have started programming a game in Java - its seems ok although im not too happy with the framerate.

Anyway more to the point, my game works fine except sometimes i get native errors when the game finishes (by sometimes i mean inconsistently; sometimes the same code doesnt produce errors)

A stack trace reveals that the error occurs when the VM tries to dispose of images.

I am using BufferStrategy for rendering and getImage to get gifs to draw.

Please help if you can!

Thanks a lot

Hello! What version of the JVM are you using? The latest official release is 1.4.1_02 and there is a 1.4.2 beta out. Both of those have relatively few issues with crashing on exit. As for performance, try taking a look at the following two libraries for examples of high speed Java2D:

GAGE - http://java.dnsalias.com (My own)
Planetation - http://www.scottshaver2000.com/template/template.php?page=planetation_main (ZParticle’s)

also, more directly relating to the crashes…

how are you closing down the application?

I’ve experienced similar improper closing down of the render pipeline when calling System.exit();

the solution, is to get the awt Thread to die naturally. By that I mean release all windows/frames etc from their native resources (by calling dispose()), and wait for the awt Thread to terminate itself.

I don’t know how this differs from an System.exit() call, but it seems a much cleaner way of disposing of the awt Thread (and Objects).

(1 problem I have noticed with this technique however, is that if u use the null parent constructor of a JWindow/JDialog, the awt thread will never terminate.
This is because a new anonymous Frame is created to act as the parent, and there is no way of disposing of this parent.)

Well, that and any sound contexts you might have opened. Once you start using JavaSound, you’re kind of SOL on automatic thread death. What I usually do is to dispose of everything I can (including the JFrame and all sound Lines), then make a call to System.exit(). If you did your cleanup correctly, you should exit cleanly. If you failed, then you crash. Seems to work pretty well. :slight_smile: