Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java 2D / Re: Subclassing Graphics Class : Possible ? on: 2003-07-28 15:03:52
I think it is pretty clear that when we try to measure the performance of an application in terms of speed of execution, there are a lot of errors generated by the probing method we are using to get the data. This is a basis of performance analysis.

I think that the problem I am experiencing is not in that area : the problem seems to be related to the high amount of short life object created (mainly Rectangles) periodically. I am only talking about memory usage, and not speed of execution (even though any excessive temporary object allocation will lead to high GC).

2  Java Game APIs & Engines / Java 2D / Re: Subclassing Graphics Class : Possible ? on: 2003-07-28 14:34:14
Hi,

I have around 50 leds flashing on my screen.

As you can see on the OptimizeIT graph, the GC activity is pretty high and you can see the memory usage growing up and down in a periodic manner.

Image:
NOT AVAILABLE

So, the main problem seems to be the high amount of Rectangle creation, followed by a high GC activity.

Does anyone have seen this kind of excessive Rectangle object creation before ?

Thanks,

Philippe
3  Java Game APIs & Engines / Java 2D / Re: Subclassing Graphics Class : Possible ? on: 2003-07-28 12:26:16
Hi,

Thanks for your answer !

I am using jdk1.3.1 under Windows 2000 with a Pentium 2.4ghz with 1gig Ram.

My application is a 2D equipment simulator composed of switches, toggles and leds. All my components are based on a generic class that is a JPanel on which I can draw back images. All the components are placed in a layered fashion and the top component window is a JFrame.

The memory problem I have was reported by the OptimizeIt profiler during a repaint operation where many leds (50) were flashing at the same time. It looks like the sunGraphics2D.transformShape() method is the one allocating the most Rectangles, followed by the graphics.hitclip() method (the overall Rectangle object allocation is around 2 megs/sec !) .

OptimizeIt screeenshot:
NOT AVAILABLE

So, my question is, there must be a way to limit the amount of Rectangle generated by the repaint operation ?

PS : I also tried to subclass the Graphics class, and I clearly saw that it was not meant to be subclassed because a lot of the double buffering mechanism was bypassed.

Phil
4  Java Game APIs & Engines / Java 2D / Subclassing Graphics Class : Possible ? on: 2003-07-25 10:48:11
Hi,

While looking for memory leaks in my application using a profiler, I just find out that the Graphics class was one of the problem !

The methods Graphics.hitClip() and Graphics.getClipBounds(r) are creating a huge amount of Rectangle objects. These methods are called from the paintchildren() of JComponent.

The distressing part is the comment I found in the Graphics class source code in the hitClip() method :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public boolean hitClip(int x, int y, int width, int height) 
{
   // Note, this implementation is not very efficient.
   // Subclasses should override this method and calculate
   // the results more directly.
   Rectangle clipRect = getClipBounds();
   if (clipRect == null) {
        return true;
   }
   return clipRect.intersects(x, y, width, height);
}


How do we subclass the Graphics class ?

The only information I found so far was the following class hierarchy :

  • public java.lang.Object
  • public abstract java.awt.Graphics
  • public abstract java.awt.Graphics2D
  • public abstract sun.java2d.SunGraphics2D
  • public sun.awt.windows.WGraphics


There are way too many abstract methods to implement in the Graphics class...

My Goal is to optimize the Graphics class for less Rectangle object creation ? Any ideas ?

Thanks,

Philippe
5  Game Development / Performance Tuning / Swing Frame Rate / Custom RepaintManager on: 2003-07-23 12:02:02
Hi,

I am writing a visual 2d equipment simulator using jdk1.3.1 under windows 2000.

I use Swing and AWT as renderer because I take advantage of the Design Time builder (bean box) to allow a fast and easy construction of simulations.

The simulations are mainly composed of reusable objects. The base class for all objects is a custom panel (JPanel) on which Images can be drawn.

Here are my questions :

1) When there are a lot of animation on screen (lets say many led objects that flashes), the memory usage of the simulation grows very fast.
I have pin pointed the problem with a Profiler (OptimizeIT) and I have discovered that the paintChildren() method of JComponent creates a lot of RECTANGLE objects to calculate the cliping area.
Is there a way to control that ?

2)  I have tried to create my own RepaintManager by subclassing the RepaintManager class. I have managed to catch all repaint() calls in the application, and force a repaint on the main application frame every 50ms using a timer, to simulate a fix frame rate. This seems to have free some of the CPU because the EventDispatcher is not longer flooded with repaint() request from all the objects. Is there anything else we can do with a Custom RepaintManager ?

3) One of the main item I have also discovered is that I am drawing all my components in a panel where cousins (siblings) components can lie on different layer on the same panel (i.e. components are added using the .add(c, 3) where 3 is a layer in JPanel).
This has a huge effect on performance since the JPanel Swing OptimizedDrawing feature (isOptimizedDrawing flag) must be set to false for the siblings components to be painted correctly. The result is that each time Swing wants to repaint a component, it must calculate the clipping area from the bottom of the hierarchy (frame) to the top (leaf component).
Is there a way to optimize the drawing without forcing swing to redraw the entire object tree ?

Any comments would be appreciated,

Thanks,

Philippe
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (35 views)
2014-12-15 09:26:44

Mr.CodeIt (26 views)
2014-12-14 19:50:38

BurntPizza (54 views)
2014-12-09 22:41:13

BurntPizza (87 views)
2014-12-08 04:46:31

JscottyBieshaar (49 views)
2014-12-05 12:39:02

SHC (64 views)
2014-12-03 16:27:13

CopyableCougar4 (67 views)
2014-11-29 21:32:03

toopeicgaming1999 (127 views)
2014-11-26 15:22:04

toopeicgaming1999 (118 views)
2014-11-26 15:20:36

toopeicgaming1999 (34 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!