Page 1 of 1

[RFD] Pointer management

Posted: 26 Sep 2005 12:11
by Hellfire
I've been working a lot with Java lately, and the thing I like best about Java is its garbage collector. The idea that I can create objects, use them and forget about them when they're not needed anymore is quite pleasing.

This brings up the issue of Pointer management. We should definitely have some guidelines on how to handle pointers, because if we don't, we will very likely end up with one big memory-leaking mess.

I have an idea for intelligent pointers, which allow (incremental) garbage collection, but I won't bore you with details unless you're interested to hear.

Disclaimer: I probably invented a wheel that has been invented many times before, but still, I'd like to hear your ideas and views on pointer management and/or garbage collection

Posted: 26 Sep 2005 12:52
by uzurpator
Maybe we should simply use one of c++ garbage collectors? Or overload new/delete words?

Posted: 26 Sep 2005 13:07
by Hellfire
I'm not suggesting that we should use a garbage collector or that we should not. I'm interested to know other people's opinions on garbage collectors. And similarly on pointer management.

Of course, using garbage collectors has some pros and cons. It gives greater freedom in programming at the expense of some extra memory usage and (sometimes) decreased performance.

Posted: 26 Sep 2005 16:19
by uzurpator
My opinion:

Garbage collector - good for sloppy programming, bad for speed, increases memory needs.
Overloaded operators - something in between
Manual memory management - fastest, but more buggy

Imho in speed oriented tasks we should use manual management, the rest can get away with a garbage collector

Posted: 26 Sep 2005 20:48
by Grunt
We are dealing with a real time game here - the speed penalty from using a garbage collector will be unacceptable, I feel.

Posted: 26 Sep 2005 23:52
by fujitsu
Yeah, I have always used manual management, but that is just the way I like to do things. Is the performance benefit big enough to turn us off using garbage collectors? Maybe we should run some tests...

William.

Posted: 27 Sep 2005 06:21
by uzurpator
fujitsu wrote:Is the performance benefit big enough to turn us off using garbage collectors?
Think Java...

Posted: 27 Sep 2005 08:08
by Hellfire
Java has more performance issues than just the garbage collector. ;)

Posted: 27 Sep 2005 08:56
by fujitsu
Hellfire wrote:Java has more performance issues than just the garbage collector. ;)
Yeah, let's see: It is byte-code interpreted... It is evil... It was created by Sun... Java = evil and slow.

William.

Posted: 27 Sep 2005 22:11
by uzurpator
Ok - so it is settled - we are hard to the core and will use manual management.

Or not?

Posted: 28 Sep 2005 09:43
by fujitsu
uzurpator wrote:Ok - so it is settled - we are hard to the core and will use manual management.

Or not?
I think speed is of the essence in such a game, so we should use manual management. I guess we just need to make sure that we delete everything we create, or we will run into... large issues. It can be a bit of a bother, but in the long run is cleaner and faster. And clean and fast is good!

William.

Posted: 28 Sep 2005 13:43
by Grunt
fujitsu wrote:[W]e just need to make sure that we delete everything we create, or we will run into... large issues.
Of course, if we miss something, our gamers will be more than happy to point this out to us. :)

Posted: 28 Sep 2005 22:06
by fujitsu
Grunt wrote:
fujitsu wrote:[W]e just need to make sure that we delete everything we create, or we will run into... large issues.
Of course, if we miss something, our gamers will be more than happy to point this out to us. :)
I think so.

Topic: "TE uses huge amounts of memory"... I can just see them there now :)

William.

Re: [RFD] Pointer management

Posted: 25 May 2009 17:51
by Jeremia
Hi Folks,

have you allready thought about using smart pointers? In my opinion it is a good mechanism for not using garbage collection, but forgetting about memory leaks at the same time. Since every class handles it's instances with reference counting. I love to use this mechanism for classes which are normaly instanciated a lot of times likes a matrix class. Another nice thing is, that this allows you to return references of objects with no problem. So you don't need to pass an object to a method if you wan't to write to it.

What do you think about using smart pointers for several classes?

Best regards

Jeremia

Re: [RFD] Pointer management

Posted: 26 May 2009 02:27
by DaleStan
Moon instructs a student

One day a student came to Moon and said: “I understand how to make a better garbage collector. We must keep a reference count of the pointers to each cons.”

Moon patiently told the student the following story:

“One day a student came to Moon and said: ‘I understand how to make a better garbage collector ...