Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
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  
  Bounded GC  (Read 1467 times)
0 Members and 1 Guest are viewing this topic.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Posted 2003-07-08 13:24:44 »

There was talk some time ago about implementing something along the lines of:

System.gc( int n );

which would tell (ask) the garbage collector to run for at most n milliseconds.  This would replace or be used in combination with the Thread.sleep( int n ) call that might appear in gaming loops.  

Alternatively there could be a way to ask the GC to run while a buffer strategy is waiting for the video sync to flip buffers.  Thus allowing the GC to optimally use the 'dead' time in a typical game or animation loop.

Has anymore thought gone into that?  Now that we have Ken here, who I read previously worked on the HotSpot team, perhaps he could comment on the feasibility or nudge the appropriate people to make this part of Java 1.5?

I think Jeff indicated that the first case of limiting the GC to N ms was quite doable according to the guys he talked to.

Offline Spiff

Senior Newbie




Java games rock!


« Reply #1 - Posted 2003-07-08 14:30:34 »

I see a problem with this. Right now there's the rule "no allocating in the main loop". Adding bounded GC would give us the rule "you can allocate some, but not enough to overwhelm what the GC can collect in about 10ms". And of course, this rule would change depending on the deployment scenario. I imagine it might be pretty hard to determine just how many new's you're allowed and of what size each new should be.

It seems to me that this would make programming harder than just using the no-allocation rule. Unless, of course, the GC can collect gobs more in a few ms than you would ever likely allocate.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #2 - Posted 2003-07-08 14:56:09 »

The "no allocation" rule is more of a guideline.  As I recall Cas mentioned that Alien Flux does some small allocations in the main loop.  Combined with other options to minimize GC delays (e.g. concurrent GC) and adjusting the heap size appropriately you should be able to allocate in the main loop if you are careful not to get carried away.

I think not allocating anything in the main loop is a very large restriction.  That alone might undo much of the productivity gains that Java otherwise would give you, as it can effect the design significantly.

And remember that if the GC is invoked for a few ms EVERY FRAME that it adds up to a significant amount.  Also, I don't see that this would do any harm.. if there will be GC interrupting the main loop it is best to have something like this to help minimize the disruption.

Turn on verbose GC (I use -Xloggc:<file>) in your game to see how frequently GC takes place and how long it runs... that will give some better idea of how effective this might be.  I would like to hear the results from anyone that would like to try that experiment actually.

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

JGO Kernel


Medals: 363
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2003-07-08 15:28:36 »

The problem is very simply, to avoid allocating so much that the processing time required to collect the garbage exceeds what time you've got left over from drawing. I can safely allocate aliens and particle emitters in my rendering loop without any trouble at all, and numerous other sundries.

I perform a full GC at opportune moments (level end), and with Jet, I already have a bounded collector.

Rather than specify the bounds using System.gc(int) it might be prudent to supply the value as a -X switch. It is, after all, only a suggestion to the garbage collector about how long it needs; if it needs more time, it'll have to use more time. In other words, I think it's a platform tuning question rather than a programmatic one. At this stage.

Cas Smiley

Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #4 - Posted 2003-07-08 19:52:17 »

Quote
Rather than specify the bounds using System.gc(int) it might be prudent to supply the value as a -X switch. It is, after all, only a suggestion to the garbage collector about how long it needs; if it needs more time, it'll have to use more time.


The way I was thinking the only time it would really take (significantly) more time was when it was triggered by an allocation that would otherwise fail.  Even in that case it would not trigger a full GC, but only enough to satisfy the allocation... a true full GC would only ever happen when System.gc() is called (with no bounds).

But I don't know enough about it, so maybe you just can't work it that way.

Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #5 - Posted 2003-07-08 21:50:51 »

We all know the GC was never tailored for Games.

Spose the key question is; should Sun (now they have a *fairly* official games division) now *re*tailor the GC so it supports the needs of Games.

I say Yeah!
We all prolly say Yeah!
All it takes is for 1 high up n00by(aka Manager :p) @Sun to say Nay, and we're all scuppered Sad

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
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.

CopyableCougar4 (23 views)
2014-08-22 19:31:30

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

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

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

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

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

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

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

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

Norakomi (41 views)
2014-08-06 19:49:38
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!