23 Feb, Jinx wrote in the 1st comment:
Votes: 0
I have a few beginner questions about gc_alloc:

1.) Has anybody implemented gc_alloc in a DikuMud and/or have advice or guidance on it?
2.) Is the effort as simple as replacing the malloc/calloc calls with gc_malloc?
3.) Can you still free your memory or do you simply let it go and let the garbage collector do it (e.g. are things like free_string then removed?)?

I've run Valgrind against my code and only found one leak, but I'd trade resources for safety and ease of use.

I've scouted github for examples in a Diku code base but haven't found any (I'm running a modified ROM 2.4 myself).

Any guidance or advice or examples would be appreciated.
24 Feb, quixadhal wrote in the 2nd comment:
Votes: 0
It would be fairly straight-forward.

Basically, when using gc_malloc, that memory allocator takes over calls to malloc/calloc/alloca, and calls to free effectively become no-ops. The garbage collection itself needs to be called periodically, and can be somewhat costly, so you'll want to put it in your main loop and interleave it with your other periodic calls so you don't try to garbage collect on the same tick you're also updating all the weather systems, or whatever else might be expensive in your game.
24 Feb, Jinx wrote in the 3rd comment:
Votes: 0
That makes sense. To check my assumption, I would no longer need to free_string something when setting it because the old reference would be collected when I call collect (this is assuming I keep the str_dup construct and swap the calls in the plumbing)?

// free_string(obj->name);
obj->name = str_dup("new keywords");

I read the initial meeting log you guys had in like 2008 where you talked a lot about cleaning the source and the str_dup conversation. It was very interesting reading, wish other logs existed.