Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Couple of questions regarding threads and objects  (Read 3252 times)
0 Members and 1 Guest are viewing this topic.
Offline GergisKhan

Junior Devvie

"C8 H10 N4 O2"

« Posted 2002-12-31 03:37:59 »

Greets folks.

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:

drawBackgrounds() // stuff like rocks, etc.
drawForegrounds() // trees, and characters

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.

Any help is most graciously appreciated.


"Go.  Teach them not to mess with us."
          -- Cao Cao, Dynasty Warriors 3
Offline trembovetski

Senior Devvie

If only I knew what I'm talking about!

« Reply #1 - Posted 2002-12-31 04:20:19 »

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.
Offline leknor

Junior Devvie


« Reply #2 - Posted 2002-12-31 04:44:55 »

I don't know of tools that answer the questions easily :-(

a) how to know if objects are being created

I don't know quite how to do this live. JSwat may work. With it you can set a breakpoint for "when a class is prepared" which I think is when a new object is created. I dunno, try it.

b) how to know WHERE objects are being created

HPmeter has a "object created by method" view

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Captain-Goatse

Junior Devvie

I suck at teh 2D. XBOX IS BIG LOL!111

« Reply #3 - Posted 2002-12-31 05:31:55 »

Make sure you are not using Java2D features since at least shear, rotate and and translate(?) create huge amounts of garbage.
Offline GergisKhan

Junior Devvie

"C8 H10 N4 O2"

« Reply #4 - Posted 2002-12-31 15:45:49 »

Thanks for that.  Pretty sure I'm not using those features, but I don't know if something may be occurring under the hood during the animation loop.


"Go.  Teach them not to mess with us."
          -- Cao Cao, Dynasty Warriors 3
Pages: [1]
  ignore  |  Print  

EgonOlsen (1672 views)
2018-06-10 19:43:48

EgonOlsen (1710 views)
2018-06-10 19:43:44

EgonOlsen (1159 views)
2018-06-10 19:43:20

DesertCoockie (1585 views)
2018-05-13 18:23:11

nelsongames (1186 views)
2018-04-24 18:15:36

nelsongames (1710 views)
2018-04-24 18:14:32

ivj94 (2533 views)
2018-03-24 14:47:39

ivj94 (1758 views)
2018-03-24 14:46:31

ivj94 (2836 views)
2018-03-24 14:43:53

Solater (971 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!