Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Dec 11, 2017 2:13 am

All times are UTC




Post new topic  Reply to topic  [ 15 posts ] 
Author Message
 Post subject: [RFD] Pointer management
PostPosted: Mon Sep 26, 2005 12:11 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
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

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)
Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+

[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...


Top
   
 Post subject:
PostPosted: Mon Sep 26, 2005 12:52 pm 
Offline
Transport Empire Moderator
Transport Empire Moderator
User avatar

Joined: Fri Jan 10, 2003 12:21 pm
Posts: 2125
Location: Wroclaw, Poland / Katowice, Poland
Maybe we should simply use one of c++ garbage collectors? Or overload new/delete words?

_________________
All art and vehicle stats I authored for TT and derivatives are as of now PUBLIC DOMAIN! Use as you see fit
Just say NO to the TT fan-art sprite licensing madness. Public domain your art as well.


Top
   
 Post subject:
PostPosted: Mon Sep 26, 2005 1:07 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
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.

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+


[ General TE Discussion ] [ TE Development ] [ TE Coding ]

Under construction...


Top
   
 Post subject:
PostPosted: Mon Sep 26, 2005 4:19 pm 
Offline
Transport Empire Moderator
Transport Empire Moderator
User avatar

Joined: Fri Jan 10, 2003 12:21 pm
Posts: 2125
Location: Wroclaw, Poland / Katowice, Poland
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

_________________
All art and vehicle stats I authored for TT and derivatives are as of now PUBLIC DOMAIN! Use as you see fit
Just say NO to the TT fan-art sprite licensing madness. Public domain your art as well.


Top
   
 Post subject:
PostPosted: Mon Sep 26, 2005 8:48 pm 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Fri Oct 03, 2003 8:22 pm
Posts: 449
Location: Edmonton, Alberta
We are dealing with a real time game here - the speed penalty from using a garbage collector will be unacceptable, I feel.

_________________
Grunt
(aka Stephan Grunt, CEO of Grunt Transport Inc. since 1994.)


Top
   
 Post subject:
PostPosted: Mon Sep 26, 2005 11:52 pm 
Offline
Engineer
Engineer

Joined: Tue Jul 12, 2005 8:14 am
Posts: 32
Location: Melbourne suburbs, Victoria, Australia (GMT+10)
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.


Top
   
 Post subject:
PostPosted: Tue Sep 27, 2005 6:21 am 
Offline
Transport Empire Moderator
Transport Empire Moderator
User avatar

Joined: Fri Jan 10, 2003 12:21 pm
Posts: 2125
Location: Wroclaw, Poland / Katowice, Poland
fujitsu wrote:
Is the performance benefit big enough to turn us off using garbage collectors?


Think Java...

_________________
All art and vehicle stats I authored for TT and derivatives are as of now PUBLIC DOMAIN! Use as you see fit
Just say NO to the TT fan-art sprite licensing madness. Public domain your art as well.


Top
   
 Post subject:
PostPosted: Tue Sep 27, 2005 8:08 am 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
Java has more performance issues than just the garbage collector. ;)

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+


[ General TE Discussion ] [ TE Development ] [ TE Coding ]

Under construction...


Top
   
 Post subject:
PostPosted: Tue Sep 27, 2005 8:56 am 
Offline
Engineer
Engineer

Joined: Tue Jul 12, 2005 8:14 am
Posts: 32
Location: Melbourne suburbs, Victoria, Australia (GMT+10)
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.


Top
   
 Post subject:
PostPosted: Tue Sep 27, 2005 10:11 pm 
Offline
Transport Empire Moderator
Transport Empire Moderator
User avatar

Joined: Fri Jan 10, 2003 12:21 pm
Posts: 2125
Location: Wroclaw, Poland / Katowice, Poland
Ok - so it is settled - we are hard to the core and will use manual management.

Or not?

_________________
All art and vehicle stats I authored for TT and derivatives are as of now PUBLIC DOMAIN! Use as you see fit
Just say NO to the TT fan-art sprite licensing madness. Public domain your art as well.


Top
   
 Post subject:
PostPosted: Wed Sep 28, 2005 9:43 am 
Offline
Engineer
Engineer

Joined: Tue Jul 12, 2005 8:14 am
Posts: 32
Location: Melbourne suburbs, Victoria, Australia (GMT+10)
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.


Top
   
 Post subject:
PostPosted: Wed Sep 28, 2005 1:43 pm 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Fri Oct 03, 2003 8:22 pm
Posts: 449
Location: Edmonton, Alberta
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. :)

_________________
Grunt

(aka Stephan Grunt, CEO of Grunt Transport Inc. since 1994.)


Top
   
 Post subject:
PostPosted: Wed Sep 28, 2005 10:06 pm 
Offline
Engineer
Engineer

Joined: Tue Jul 12, 2005 8:14 am
Posts: 32
Location: Melbourne suburbs, Victoria, Australia (GMT+10)
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.


Top
   
PostPosted: Mon May 25, 2009 5:51 pm 
Offline
Engineer
Engineer

Joined: Mon May 25, 2009 5:21 pm
Posts: 2
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


Top
   
PostPosted: Tue May 26, 2009 2:27 am 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
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 ...

_________________
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.