Experiences with GC in game programming

  • Thread starter Thread starter cody
  • Start date Start date
C

cody

Is here anybody who has experience with GC in games or selfrunning demos? Is
the GC pausing the game noticeable? If yes, is it possible to preallocate
almost everything so that GC only needs to run every >5minutes, that would
be acceptable.
Any suggestions or experiences or tips are very welcome!
 
As long as the memory is there you have quite a few options. I tend to use
object
pooling as much as possible, rather than creating new objects and letting them
go.
There are some issues with clean-up of any pooled objects, but it works fairly
well
if you create yourself a generic pool manager with some interfaces that get
called to
make sure objects are cleaned up and prepared to be sent back out.

The Terrarium runs for quite some time, many days in some cases. So far the
only
true GC issue we've had with this project got into the framework before it
released.
The Terrarium doesn't have any noticeable lag, unless creatures go over, none
due to
GC mind you, and we constantly have creatures allocating new objects outside of
our control.

If you have a specific use case in mind, that would probably be better than
generically
fishing for information. Note, you are always going to have gen0 collections
firing.
 
If you put your mind to it it is certainly possible to create a render loop
that uses close zero allocations from top to bottom at the cost of some
extra memory. You can certainly create one that only makes use of only GC0
and never does GC1/2 which are much more expensive and if you do those a lot
you *will* notice. I have done this and it works pretty well... I wouldn't
say what I am building is UT 2003 quality by any stretch of the imagination,
but it does do a lot of texture/geometry changes and doesn't jitter a bit.
In fact I also have multiple videos playing and am currently not even making
use of the VMR but I still don't have any nasty pauses.

I also go to great pains never to issue redundant render state changes. I
don't know if it is worth the effort I put in to get it down to zero but I
guess every little helps.

Depending on what you want to do, MDX seems good enough for a lot of apps
IMHO.

Christian
 
Animated VG.net applications never seem to pause for a GC. We create small
number of small temporary objects during the display pass but they all seem
to be collected efficiently. Typically our animated demos use a small
fraction of the CPU available, so I imagine the GC is occurring in small
spikes of CPU usage that are short enough to prevent a pause.

Regards,
Frank Hileman
Prodige Software Corporation

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated VS.net graphics editor
 
Back
Top