FrontPage User Control Panel Browse Our Members View Calendar Register Today!
Get New Posts! View Faq?

Not A Member Yet? Register today and become part of the community.

Go Back   GDI Forums > Game Development > General Programming

View Poll Results: Would you use these C++ features in your Game/Engine
I Wish there was Garbage Collection in C++ 0 0%
Will use Exception handling only 1 20.00%
Nah.. Would write my own shit.. 1 20.00%
Couldnt care less.. I am happy with my Log files & dumps 3 60.00%
Voters: 5. You may not vote on this poll

Reply
 
Thread Tools Display Modes
Old 07-23-2007, 06:25 AM   #1
KC_SkeletalMesh
Almost lives his life at this place..
 
KC_SkeletalMesh's Avatar
 
Join Date: Apr 2007
Location: Hyderabad
Posts: 90
Send a message via MSN to KC_SkeletalMesh Send a message via Yahoo to KC_SkeletalMesh Send a message via Skype™ to KC_SkeletalMesh
Default C++ Garbage Collection & Exception Handling in Game Engines

Hi there fellas,

(EDIT: Corrected the mistake of including GC as a built in feature of C++. - KC )

This is to gather ideas on what people think of using C++ Exception handling features. Its a known thing that game(engine) developers have refrained from it due to performance hit.

Given the CPU computation power we have right now, do you think its worth it ?

What are the advantages, disadvantages and alternatives ?
Status: Offline
 
Reply With Quote
Old 07-23-2007, 07:18 AM   #2
Specchum
Super Moderator
 
Specchum's Avatar
 
Join Date: Apr 2007
Location: Mumbai
Posts: 91
Default

I suppose GC is a new feature of the revised C++ standards? I actually am interested in knowing the performance overhead for using GC. At the moment I'm sticking to my log and dump files and use exception handling very, very sparingly.

Having said that I quite like the GC feature in C# wherein I don't have to worry too much about memory leaks. Does lower the stress levels quite a bit!

I would seriously consider using GC if the overhead is acceptable. Exception handling.. maybe not.
Status: Offline
 
Reply With Quote
Old 07-24-2007, 04:06 AM   #3
dance_of_death
Okie Dokie Activity member
 
dance_of_death's Avatar
 
Join Date: May 2007
Location: Hyderabad / Mumbai
Posts: 41
Send a message via Yahoo to dance_of_death
Default yups!

am with specchum for this...
i'll probably stick with log files instead of going for Exception handling... but my reason for it is diferent ... coz i have never really bothered to use exception so far ...
__________________
I will hope, my soul will fly, so I will live forever
Heart will die, my soul will fly, and I will live forever
Status: Offline
 
Reply With Quote
Old 07-24-2007, 04:03 PM   #4
Vishesh
Okie Dokie Activity member
 
Vishesh's Avatar
 
Join Date: May 2007
Location: Delhi
Posts: 29
Send a message via Yahoo to Vishesh
Default

There is garbage collection in C++ !!
Since when ?

Of w8 you must be talking about auto pointer and smart pointers (boost).

I don't qualify as a game developer but I would still love using exception handling, at least currently I would. The current game I'm working on (2d platform) could really benefit from it unfortunately my compiler does not support it. My own error handling mechanism isn't that great and is giving horrible errors.

I prefer using new and delete instead of GC.....but then again thats only cause I have not ever bothered to learn how to use any alternatives...
__________________

Last edited by Vishesh : 07-25-2007 at 10:29 AM.
Status: Offline
 
Reply With Quote
Old 07-25-2007, 05:39 AM   #5
KC_SkeletalMesh
Almost lives his life at this place..
 
KC_SkeletalMesh's Avatar
 
Join Date: Apr 2007
Location: Hyderabad
Posts: 90
Send a message via MSN to KC_SkeletalMesh Send a message via Yahoo to KC_SkeletalMesh Send a message via Skype™ to KC_SkeletalMesh
Default

Quote:
Originally Posted by Vishesh View Post
There is garbage collection in C++ !!
Since when ?
My mistake regarding Garbage Collection in C++. The question is more of 'Garbage Collection, if available is of any use for game developers' ?

Recently I was discussing with a colleague on the idea of choosing Java as language for developing a real-time engine which is supposed to work in Windows only.

So, my point in the debate was, when you do not need cross-platform, and the app is does not run in a browser, why use Java ? Its considerably slower than C++ binaries, for a real time game engine.

His argument was that GC actually improves speed. Which I never agreed with obviously
Status: Offline
 
Reply With Quote
Old 07-25-2007, 05:54 AM   #6
KC_SkeletalMesh
Almost lives his life at this place..
 
KC_SkeletalMesh's Avatar
 
Join Date: Apr 2007
Location: Hyderabad
Posts: 90
Send a message via MSN to KC_SkeletalMesh Send a message via Yahoo to KC_SkeletalMesh Send a message via Skype™ to KC_SkeletalMesh
Default

Quote:
Originally Posted by Vishesh View Post
There is garbage collection in C++ !!
Of w8 you must be talking about auto pointer and smart pointers (boost).
Yes smart pointers ( boost libs on the whole ) are gonna be standardized by C++ Standards review group. Boost is definitely cool stuff.

However, some game-engines already use Smart pointers. For ex. Gamebryo uses Smart pointers using their built-in template class.

Personally, I don't prefer Smart pointers. At the most, I would derive from a ReferenceCounter base class for stuff like Texture resource objects & Resource managers. Having coded pretty tight C++ code for about 10 years, making sure I delete stuff is kinda second nature. Most of my time and thought goes onto the actual functionality at hand.
Status: Offline
 
Reply With Quote
Old 07-25-2007, 11:23 AM   #7
riddler
Forums Noobie.
 
riddler's Avatar
 
Join Date: Apr 2007
Posts: 12
Default

I would recommend having another look at smart pointers. Using them is like wearing a helmet while riding a bike. Check out Andrei Alexandrescu's discussion on smart pointers in his book "Modern C++ Design". I am certain any behaviour you want from them, you can get using his methods. It is an advanced book and not easy reading though.
Status: Offline
 
Reply With Quote
Old 06-03-2008, 09:35 PM   #8
arca1n
Okie Dokie Activity member
 
Join Date: Apr 2007
Posts: 20
Post GC with Managed Object Pools

managed vs native code has been a topic of debate for as long as both the approaches have been compared on the same plane. Now GC is an overhead for sure, then so is deleting objects in a running game, especially the high frequency code like the particle systems etc. In such cases a ploy that works is using Managed Object Pools where the object doesn't get deleted from the memory but simply goes back to an existing object pool to be reused. Yes, this technique requires strict analysis of the problem at hand and a lot of thinking on the design level. But by ensuring that less and less garbage gets collected, it reduces a lot of overhead on the GC. Haven't had the chance to profile 2 object pools and compare their performance, but in theory this approach should scale to a modest 60fps requirement...
Status: Offline
 
Reply With Quote
Old 06-04-2008, 01:34 PM   #9
gautam
Forums Noobie.
 
Join Date: Aug 2007
Posts: 2
Default

Few question to ask is -
1. Do you require exception handling.
2. Does the code bloat or increase in executable size and memory usage effect you in anyway. For eg:- On Nintendo DS/PS2 it definitely will.
3. Is your program critical that it should never fail and any exception should be caught and handled in a decent manner ?

I know quite a few game engines (including ones on console) which use it. And it has its advantages and disadvantages. Surprisingly Exception handling can come in the way a lot if you are developing on console due to which you just tend to avoid it.

Just because something exists doesn't mean you use it. I am pretty sure that 80% of the C++ programmers don't use almost 80% of what C++ has to offer.

Garbage Collection - if you are talking Smart Pointers - then its a definite yes. Its worth the trouble rather than not. Better safe than sorry.
Status: Offline
 
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 10:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2007, Jelsoft Enterprises Ltd.