Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
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  
  GC problem in 2D platform game?  (Read 732 times)
0 Members and 1 Guest are viewing this topic.
Offline TheAnalogKid

JGO Coder


Projects: 2



« Posted 2003-12-11 14:45:08 »

Hi all,

I'm writting a 2D platform game and I think I have a memory issue.  Here is the log of the game:


D:\game_dev>set VM_OPTIONS=-Xms32m -Xmx64m -Dsun.java2d.accthreshold=0 -verbose:gc -XX:+PrintGCTimeStamps

D:\game_dev>java -cp bin;lib/dom4j.jar;lib/gage_timer-1_0.jar;lib/jutils.jar;lib/jinput.jar;lib/dxinput.jar -Djava.library.path=lib -Xms32m -Xmx64m -D
sun.java2d.accthreshold=0 -verbose:gc -XX:+PrintGCTimeStamps bubblegame.BubbleGame
0.000: [GC 2111K->222K(32576K), 0.0215583 secs]
Running at 85 hertz
New Acceleration Threshold: 0
[11-Dec-2003 12:10:46 PM] INFO - loading map...
[11-Dec-2003 12:10:46 PM] INFO - Found Chunk - MPHD, reading...
[11-Dec-2003 12:10:46 PM] INFO -   loading map header.
[11-Dec-2003 12:10:46 PM] INFO -   FMP version   : 1.0
[11-Dec-2003 12:10:46 PM] INFO -   MapWidth      : 300
[11-Dec-2003 12:10:46 PM] INFO -   MapHeight     : 80
[11-Dec-2003 12:10:46 PM] INFO -   BlockWidth    : 32
[11-Dec-2003 12:10:46 PM] INFO -   BlockHeight   : 32
[11-Dec-2003 12:10:46 PM] INFO -   ColourDepth   : 32
[11-Dec-2003 12:10:46 PM] INFO -   BlockByteSize : 32
[11-Dec-2003 12:10:46 PM] INFO -   NoOfBlocks    : 1283
[11-Dec-2003 12:10:46 PM] INFO -   NoOfImages    : 1266
[11-Dec-2003 12:10:46 PM] INFO - Found Chunk - EDHD, skipping...
[11-Dec-2003 12:10:46 PM] INFO - Found Chunk - CMAP, reading...
[11-Dec-2003 12:10:46 PM] INFO -   loading 256 entries.
[11-Dec-2003 12:10:46 PM] INFO - Found Chunk - BKDT, reading...
[11-Dec-2003 12:10:46 PM] INFO -   loading 1283 blocks.
[11-Dec-2003 12:10:46 PM] INFO - Found Chunk - BGFX, reading...
[11-Dec-2003 12:10:46 PM] INFO -   loading 1266 images.
4.512: [GC 2333K->1392K(32576K), 0.0330226 secs]
4.703: [GC 3502K->1938K(32576K), 0.0141814 secs]
4.902: [GC 4050K->2503K(32576K), 0.0148150 secs]
5.131: [GC 4615K->3724K(32576K), 0.0205685 secs]
5.382: [GC 5834K->4205K(32576K), 0.0115557 secs]
5.579: [GC 6315K->5444K(32576K), 0.0200933 secs]
5.769: [GC 7556K->5922K(32576K), 0.0114517 secs]
5.923: [GC 8034K->6419K(32576K), 0.0124315 secs]
6.127: [GC 8529K->7360K(32576K), 0.0159188 secs]
[11-Dec-2003 12:10:48 PM] INFO - Found Chunk - BODY, reading...
[11-Dec-2003 12:10:48 PM] INFO - Found Chunk - LYR1, reading...
[11-Dec-2003 12:10:48 PM] INFO - Map loaded succesfully.
7.127: [GC 9472K->8017K(32576K), 0.0169907 secs]
7.822: [GC 10118K->9432K(32576K), 0.0185303 secs]
8.126: [GC 11500K->10386K(32576K), 0.0125689 secs]
Number of buffers used: 3

Available accelerated memory (in bytes): 25898752
8.662: [GC 12498K->11158K(32576K), 0.0132754 secs]
Windows 2000
Ticks/Second: 1193182
Ticks/Frame: 14037
27.735: [GC 13270K->11214K(32576K), 0.0090187 secs]
72.364: [GC 13326K->11223K(32576K), 0.0037304 secs]
BufferStrategy was page flipping.

fps : 85.0
Game Duration: 112 seconds
110.193: [GC 13335K->12053K(32576K), 0.0188094 secs]


You can see in the 2 last bold lines that the GC frees about 2 megs of memory.  This behavior will continue until the program terminates.

The strange thing about this is that my code doesn't create that much objects to fill 2 megs of memory regularly.  The only object I create is String to display the fps BUT only when the fps value changes and I've commented out these lines of code and there is still a lot of garbage.  So is someone could help me to explain this undesired behavior?  

The game runs with the resolution of 640x480x16 at 85 hertzs with 3 buffers to do  page flipping.

You can see the VM options I pass to the VM.  I use JDK 1.4.2_02, it runs on Win 2000 with a Pentium 3 866 and a  GeForce TNT 2 32 megs.

Any idea?

I really don't see what happens here.

Thanks  

Offline trembovetski

Senior Duke




If only I knew what I'm talking about!


« Reply #1 - Posted 2003-12-12 04:50:24 »

For some rendering operations Java2D has to create intermediate buffers. This happens in most cases of non-simple transforms (like rotation), some image format conversions.

You might want to use some profiling tool to find out what objects are being created. For example, you can use the built-in profiler (Xrunhprof:help). Make you app quit after a few frames and see what's left on the heap.

Also, check out what primitives your app is using, with tracing: -Dsun.java2d.trace=help and see if there are some 'generic' loops that are being used, or mask blit operations.
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.

Longarmx (35 views)
2014-10-17 03:59:02

Norakomi (25 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (74 views)
2014-10-11 22:30:10
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!