Garbage Collection and gamedev - tl;dr Yes we want it, so let's solve it

random frederick.mueller at
Sun Nov 22 20:49:19 UTC 2020

On Sunday, 22 November 2020 at 19:54:14 UTC, Ethan wrote:
> One of the things I mentioned is that I don't get why library 
> solutions are pursued for handling memory allocations/garbage 
> collecting when the runtime already exists and can be used for 
> the same purpose.

A benefit of the library solution is that the user can always 
create their own
implementation when needed.
You can write your own malloc in C, which is useful if you want 
to program an os... (for example)

> A library solution actively requires the user to specify the 
> kind of memory management they want. This is not what most 
> modern programmers need to care about. A runtime solution means 
> that if you want to switch between ARC GC and a traditional 
> mark/sweep GC then you just swap the runtime implementation 
> out. The user's code does not change, and it should not need to.

I'm not a gamedev but I can imagine that (unlike most 
programmers) they care about it.
You might want to use ARC for resources on the GPU, but mark and 
sweep on CPU.
You could use region-based memory management for some objects to 
optimize performance.

> So tl;dr - DIP, but I can't think about writing one for a few 
> months because time, but there's bound to be interesting 
> discussion that can come up as a result of this.

Would it be possible that you have different pointer types, but 
code which doesn't care about it is somehow generic?

More information about the Digitalmars-d mailing list