Leopard's garbage collection in action games, yay or nay?

Apprentice
Posts: 15
Joined: 2007.02
Post: #1
As I'm currently working on a base code template for future projects, I've been looking into possibly taking advantage of the new garbage collection feature in Objective-C 2.0. I'm already hooked on properties and fast enumeration, so I'm already intending to stay Leopard only from now on. Using GC will be purely a performance/ease of coding tradeoff for me.

I've read about the performance penalties involved, especially when a full collection is done. What I don't know is what those penalties generally amount to in practice, and before I jump in feet first I'd like to hear some feedback on it from others who have used it, especially in fast action games. Can it introduce stuttering/lag/hateful beachball when collection occurs, or is it more or less unobtrusive as long as you aren't constantly allocating a bazillion objects?

Should I stick to RC memory management or stop worrying and learn to love the GC? :P
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #2
Sea Manky Wrote:As I'm currently working on a base code template for future projects, I've been looking into possibly taking advantage of the new garbage collection feature in Objective-C 2.0. I'm already hooked on properties and fast enumeration, so I'm already intending to stay Leopard only from now on. Using GC will be purely a performance/ease of coding tradeoff for me.

I've read about the performance penalties involved, especially when a full collection is done. What I don't know is what those penalties generally amount to in practice, and before I jump in feet first I'd like to hear some feedback on it from others who have used it, especially in fast action games. Can it introduce stuttering/lag/hateful beachball when collection occurs, or is it more or less unobtrusive as long as you aren't constantly allocating a bazillion objects?

Should I stick to RC memory management or stop worrying and learn to love the GC? Rasp

I don't know much about the Leopard GC model, but this is a good question. I can't imagine that it's prohibitively slow or cumbersome. The other GC models I have dealt with (Java mostly) are quite fast and unobtrusive. If you're running your game at 25 FPS to begin with, you may have some issues, but I would bet that if your game is running at a high enough rate, GC will be no problem.

Please someone stop me if I'm talking crazy here. Again, I have no experience with the Leopard implementation of GC and am basing these observations on experience with other GC models.

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #3
How about just avoiding dynamic allocations per frame altogether?

Regardless of the memory management scheme used, you want your resident footprint to be static once you're running.
Quote this message in a reply
Apprentice
Posts: 15
Joined: 2007.02
Post: #4
For the projects I want to do, dynamic creation of game objects, enemies, bullets, what have you will happen. I'll certainly try to minimize what I can, but there's going to be some. And then there's the creation of objects associated with the HID library queues and the rest of the frameworks. The stuff I'm doing isn't going to be so taxing on a Leopard capable system that I'll need to optimize my game logic to the point where I never allocate any memory. But if Apple's GC is clunky enough to cause noticeable pauses, I'd like to avoid using it.

I just want to hear from people who've used the new garbage collection in their games, and if it adversely affected performance to a significant degree.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
I doubt there's anyone who's used the new GC in games out there to comment, honestly... it's fairly new, and game developers are likely to be the most risk-averse folks to adopting it.
Quote this message in a reply
Apprentice
Posts: 15
Joined: 2007.02
Post: #6
I thought that might be the case, though I held out hope that someone had tried it, seeing as it's nearly a year old now.

Oh well, if nobody replies, I'll continue with my normal RC usage, but also create finalizing methods and keep GC in mind as I code, and try it both ways on the next completed project.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Errors in Xcode When Using Garbage Collection Muskrat 2 2,609 Oct 20, 2008 07:42 PM
Last Post: Muskrat