Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  avoiding FULL GCs  (Read 2881 times)
0 Members and 1 Guest are viewing this topic.
Offline emzic

Senior Member





« Posted 2006-06-20 14:11:45 »

hello,

i noticed, that whenever a full garbage collection kicks in, the complete game is halted for about 0.1 second, which is of course extremely noticeable in a scrolling game.

now i was wondering, if there is any way to avoid these full garbage collections and only do the "regular" garbage collections. maybe by using a jvm argument?

thanks!

www.embege.com - personal website
webstart blendinspect - OpenGL BlendingModes visualization.
Offline princec

JGO Kernel


Medals: 378
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2006-06-20 15:02:50 »

There's no way to completely avoid full GC but there are some tricks you can use.
Firstly, don't generate so much garbage if you can help it Wink
Secondly, try tuning the heap size so the amount of garbage that can accumulate before a collection isn't so big
Thirdly, try the incremental collector (-Xincgc) and/or the parallel collector (can't remember the switch).
Fourthly, try calling System.gc() at points in the game where a GC won't be noticed (in between levels for example)

Cas Smiley

Offline emzic

Senior Member





« Reply #2 - Posted 2006-06-20 20:12:09 »

thanks for your answer,

onto your second point, setting the heapsizes with -Xms and -Xmx what are good values for that? and what are the default values?

www.embege.com - personal website
webstart blendinspect - OpenGL BlendingModes visualization.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 378
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2006-06-20 20:50:11 »

I can't remember -Xms's default but -Xmx defaults to 64mb. You might not need quite so much.
There's a new flag now, -XX:+UseAdaptiveSizePolicy, which tunes the size of the Eden space as well, which helps prevent stuff getting promoted into the main heap too early in the first place.

Cas Smiley

Offline Jeff

JGO Coder




Got any cats?


« Reply #4 - Posted 2006-06-20 21:09:24 »

Setting the max heap size is always a trade off.

The larger it is, the less often you will fullGC, but the greater the pause wil lbe when it does.
Also you NEVER want tos et max heap so big you start swapping to disk at run-time.

As much as  possible, if you can get away with it (you cant always) it good to let the system work these thinsg out.

I think however you may be putting the cart before the horse. You have not yet determiend *why* yo uare seeing full GCs during game-play.  Most games dont because they only do two kidsn of allocations:
(a) Short lived objects that live in the eden space and never promote.
(b) Objects that exist for the entire level and only get freed up and GCd at level chnage.

Step one of performance tunign is always, always, always to profile your code.  It might be that it is an object leak that is causing your entire problem.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline emzic

Senior Member





« Reply #5 - Posted 2006-06-21 07:57:00 »

ok, thanks again everybody.

it seems i am generating a lot of garbage due to calculation while the player moves around and due to network messages.

btw: which profiler do you recommend (i am using eclipse)
there seem to be really lot of them and i dont wanna try every single one out.

thanks!

edit: btw: is there any way to be notified when a FULL GC happens, other than -verbose:gc? maybe from inside the code?

www.embege.com - personal website
webstart blendinspect - OpenGL BlendingModes visualization.
Online cylab

JGO Ninja


Medals: 49



« Reply #6 - Posted 2006-06-21 08:37:49 »

Maybe you can find something helpful there: Java Garbage Collection Tuning

Mathias - I Know What [you] Did Last Summer!
Offline Jeff

JGO Coder




Got any cats?


« Reply #7 - Posted 2006-06-22 03:58:11 »

ok, thanks again everybody.

it seems i am generating a lot of garbage due to calculation while the player moves around and due to network messages.

WHich shoudl be short lived yes?

So it shoiuldnt be causing a full GC.  Something esle is definitely going on...

Quote
btw: which profiler do you recommend (i am using eclipse)

Ive searched and have yet to find a good, usuabl;e, free profiler for Eclipse.

The best free profielr i knwo of is unfrotunately specific to netbeans.  You can fidn it on the netbeans page.

there seem to be really lot of them and i dont wanna try every single one out.


Quote
edit: btw: is there any way to be notified when a FULL GC happens, other than -verbose:gc? maybe from inside the code?

nope, EXCEPT by connecting to the JPDA (Java Profilign and Debugging Interface), which is hat a profiler does.
But this has an impact on your code performance.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline funsheep

Senior Newbie




Java games rock!


« Reply #8 - Posted 2006-06-22 08:32:48 »

my secret tip:

http://jiprof.sourceforge.net/

and a tutorial for usage:
http://www-128.ibm.com/developerworks/java/library/j-jip/?ca=dgr-lnxw01JavaProfiling#resources

the profiler takes advantage of the Java 1.5 agent interface, it hooks up direktly to the vm, causing much less impakt on performance of the messured application
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.

Dwinin (28 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (74 views)
2014-09-10 06:39:09

Tekkerue (37 views)
2014-09-09 02:24:56

mitcheeb (57 views)
2014-09-08 06:06:29

BurntPizza (44 views)
2014-09-07 01:13:42

Longarmx (28 views)
2014-09-07 01:12:14

Longarmx (34 views)
2014-09-07 01:11:22

Longarmx (34 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
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!