I'm trying to work out some issues in my animation loop. I can post code if desired; however, I'm not really sure the code is helpful just yet.

I need to figure out a way to determine a) how to know if objects are being created, b) how to know WHERE objects are being created, and c) how to eliminate object creation in my animation thread.

That said, let me give you the psuedo code.

Most of my graphics are stored as an Image in an Image[] so that I can access them by index. I have precalculated transitions on my ground terrain, so the procedure for drawing transition tiles is straight lookup. My loop looks like:

I am not sure why, but there is a significant hesitation every once in a while. I am almost positive it is related to garbage collection, but I have no idea what garbage I am creating that would need to be collected!

Reference information: this is running in Java 1.3.1, on a JPanel that is 512x512. I maintain a primitive array of two BufferedImages that are used as offscreen buffers so that I can start drawing on the next one as the first one is drawn to the screen. I did this because at one point I was not sure that the drawing loop would complete in the time it takes to draw the buffer to the screen. The BufferedImages are optimized as per other threads on this board to minimize the impact of transparency on them; I believe they are RGB BufferedImages with no alpha. The terrains are RGB, the transitions and backgrounds and foregrounds and chars are all ARGB.

There's a number of profiler tools which could help you in determinig the hot spots in your app.

You can start with the built-in heap profiler (java -Xrunhprof:help)or use one of the known profiler tools on the market (like OptimizeIt). The idea is to get a baseline before a step in your app, make a step (like render one frame), and then check out the newly created objects.

It's hard to say what's wrong with your app, but 1.3.1 (1.4 to a lesser extent) is known to create intermediate image buffers for some opertations - for example, when you transform an image, or if there's no optimized loop for the particular image format you're using.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org