Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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 1604 times)
0 Members and 1 Guest are viewing this topic.
Offline GergisKhan

Junior Member




"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:

drawTerrain()
drawTransitions()
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.


gK

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

Senior Member




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 Member




ROCK!!!


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

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

Quote
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.

Quote
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 Member




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 Member




"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.


gK

"Go.  Teach them not to mess with us."
          -- Cao Cao, Dynasty Warriors 3
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (14 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (59 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
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!