Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Google, Yahoo!

Members: 0
Guests: 9
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Garbage Collection?
Forum Rules | Mark all | Recent Posts

Garbage Collection?
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 24, 2011, 6:57 pm
Go to the top of the page
Go to the bottom of the page

Quixadhal
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005

I haven't been doing much in the Dikurivative scene lately, but I figured I'd poke my head back over here and see what ya'll have been doing. :)

I had an idea a while ago, and was wondering if anyone has tried it yet. There is a very nice library called gc, which appears to have a license option that would be compatible for inclusion (IE: not GPL).

What this does, is replace the system malloc and C++ new operators with a garbage-collecting malloc system. The free function becomes a no-op, and C++ delete destroys the object but doesn't free resources. Instead, the garbage collection system tracks anything which has a reference to anything in it, and when the reference count on a chunk of memory drops to zero, it is freed automatically.

This is how most modern languages work, although they hide the details from you.

Sooooo, I was wondering if anyone had tried this with SmaugFUSS? It would probably make the code a bit cleaner, and it would certainly make a whole class of pointer errors go away (not all of them, alas).

Discuss?
       
Post is unread #2 Mar 24, 2011, 7:28 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

I haven't messed with it, but I might look into it when I have a chance one of these days. Maybe as a project after I get space finished for TSW.
       
Post is unread #3 Mar 24, 2011, 7:51 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

I looked into that sort of thing ages ago when I was doing the AFKMud conversion. At the time though I didn't really get the point and wasn't up to the task of retooling an entire system to use it.

Not that I'm really up to the task of doing that now, but at least I know what the point is and that it's definitely a much better way of doing things. I certainly don't oppose the idea of using it in SmaugFUSS at some point.
       
Post is unread #4 Mar 28, 2011, 7:25 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,866
JoinedJul 26, 2005

Should give more to go on then just what was said and maybe an example of how to do it etc... I remember looking into this way back when Samson was considering it and looked like a headache lol. Been a long time now though maybe more info has come out on it etc...
       
Post is unread #5 Mar 28, 2011, 7:37 pm
Go to the top of the page
Go to the bottom of the page

Quixadhal
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005

Well, the ideal solution is to drop libgc into place and let it replace malloc/calloc/realloc and new, and then replace free with a no-op.

IF you manage to force all memory allocation to happen through libgc, it doesn't matter if you have free calls in place or not. The only gotcha I can see is the overly complicated shared-string code and the prototype reuse code that tries to NOT actually free stuff but track it for recycling.

Ideally, you want to NOT do that anymore, since garbage collection already tracks things and frees them when no references are left.

Step one would be to build a list of all the places that allocate/free memory (and how), and then see how many things use the recycling code and how hard it would be to stop doing so.

On the plus side, you don't need to do it all at once. Just hooking libgc in and replacing the default memory allocators will probably work without much of a change at all.
       
Post is unread #6 Apr 21, 2011, 6:28 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,866
JoinedJul 26, 2005

Well for the most part I got rid of the whole reusing of pointers for objects long ago in LoP so should be fairly good on that point. I might actually look into doing what you suggested this weekend just to see how it works out lol.
       
Pages:<< prev 1 next >>