August 02, 2021

On Sunday, 1 August 2021 at 14:43:47 UTC, evilrat wrote:

>

What this means in practice - it should be possible to go full OOP crap for game simulation using lightweight classes without any hiccups even with GC enabled, but all asset data should be handled differently and taken out of GC scannable heap to avoid long pauses.

I'm kind of skeptical towards tracing GC for games. Think of thousands of objects, usually of the same type. These objects are often full of references to other objects and they often points to each other as there might be some relation.

This is a lot of memory, that is also scattered around in the memory. Scanning these will take time. For this type of objects I would go for a pool that is outside GC. Also how the reference each other could be solved by reference counting in order to minimize memory leaks. Other suggestions is that object references each other using a hash table. This rolling identifier/hash lookup is often used in operating systems (file handles for example) as pointers cannot be used in order to distinguish a resource.

Often memory management in games kind of falls outside the convenience of GC as the demand is so special, not only because of performance but also when it comes to data structures.

August 02, 2021

On Monday, 2 August 2021 at 15:43:24 UTC, IGotD- wrote:

>

On Sunday, 1 August 2021 at 14:43:47 UTC, evilrat wrote:

>

What this means in practice - it should be possible to go full OOP crap for game simulation using lightweight classes without any hiccups even with GC enabled, but all asset data should be handled differently and taken out of GC scannable heap to avoid long pauses.

I'm kind of skeptical towards tracing GC for games. Think of thousands of objects, usually of the same type. These objects are often full of references to other objects and they often points to each other as there might be some relation.

This is a lot of memory, that is also scattered around in the memory. Scanning these will take time. For this type of objects I would go for a pool that is outside GC. Also how the reference each other could be solved by reference counting in order to minimize memory leaks. Other suggestions is that object references each other using a hash table. This rolling identifier/hash lookup is often used in operating systems (file handles for example) as pointers cannot be used in order to distinguish a resource.

Often memory management in games kind of falls outside the convenience of GC as the demand is so special, not only because of performance but also when it comes to data structures.

Of course, that's why I mentioned that, even if GC performance is OK it is still better to design with what you've said in mind.

August 02, 2021

On Monday, 2 August 2021 at 15:43:24 UTC, IGotD- wrote:

>

On Sunday, 1 August 2021 at 14:43:47 UTC, evilrat wrote:

>

What this means in practice - it should be possible to go full OOP crap for game simulation using lightweight classes without any hiccups even with GC enabled, but all asset data should be handled differently and taken out of GC scannable heap to avoid long pauses.

I'm kind of skeptical towards tracing GC for games. Think of thousands of objects, usually of the same type. These objects are often full of references to other objects and they often points to each other as there might be some relation.

This is a lot of memory, that is also scattered around in the memory. Scanning these will take time. For this type of objects
I would go for a pool that is outside GC. Also how the reference each other could be solved by reference counting in order to minimize memory leaks. Other suggestions is that object references each other using a hash table. This rolling identifier/hash lookup is often used in operating systems (file handles for example) as pointers cannot be used in order to distinguish a resource.

Often memory management in games kind of falls outside the convenience of GC as the demand is so special, not only because of performance but also when it comes to data structures.

It is more than enough for Flash like games, honestly plenty of indies will never make it beyond that, so why bother for the ultimate weapon if they they on the first day on the battlefield?

Don't dismiss languages on how well they can achieve Fortnight, when not even able to beat Stardew Valley or Bastion sales.

August 02, 2021

On Monday, 2 August 2021 at 18:10:03 UTC, Paulo Pnito wrote:

>

It is more than enough for Flash like games, honestly plenty of indies will never make it beyond that, so why bother for the ultimate weapon if they they on the first day on the battlefield?

Don't dismiss languages on how well they can achieve Fortnight, when not even able to beat Stardew Valley or Bastion sales.

Depends on what you are aiming for, for smaller games GC is probably enough. Let's not forget this interesting D conf seminar.

https://www.youtube.com/watch?v=7YjLW7anNfc

Where the solution was to disable the GC collecting. For people who haven't seen it this could be interesting as it is the only what I know of example where D is used in a high budget game.

August 03, 2021
On 02/08/2021 9:32 PM, evilrat wrote:
> unless there is already some fork mechanism on Windows that i'm not aware of.

There is snapshoting which is essentially a fork without any threads that you can introspect from your host process.
August 02, 2021
On Mon, Aug 02, 2021 at 03:43:24PM +0000, IGotD- via Digitalmars-d wrote: [...]
> I'm kind of skeptical towards tracing GC for games. Think of thousands of objects, usually of the same type. These objects are often full of references to other objects and they often points to each other as there might be some relation.
[...]

I don't have that much experience with game programming, but have experimented with things like ECS, which kinda solves this problem at least partially, by keeping everything in arrays.  References between objects are represented by entity IDs rather than straight pointers, and arrays can be allocated in large blocks at a time instead of one allocation per object, so there's much less GC pressure.  ECS is also more conducive to representing in-game objects than OO-style objects IMO, especially in games where objects can undergo extensive changes that aren't easily mapped to the OO paradigm.

Of course, an ECS implementation could also just manage its own memory instead of relying on GC.  In any case, high performance + frequent allocation of small objects == trouble (even if you manually manage memory with malloc/free).  If you find yourself in that situation, you inevitably have to address a lot of the same kind of issues that ECS addresses anyway.  So this problem isn't necessarily GC-specific (though it tends to become more evident in GC environments), but a more general problem of memory management and object representation in games.


T

-- 
MASM = Mana Ada Sistem, Man!
August 03, 2021

On Sunday, 1 August 2021 at 08:54:05 UTC, Kirill wrote:

>

It's interesting to hear do you use D's GC? Or do you use your own custom memory management structure?

How performant is GC?

The reason I'm asking is I'm planning to dive into 3D game dev with D as a hobby in an attempt to create a game I dreamed of since I was a kid. I'd like to know if GC is worth using at all, or should I go with 100% manual memory management.

Any opinion is appreciated. Thanks in advance.

The D language claim support NOGC Programming, but there is no ecosystem for this. It force people to use GC if they want use library.

D GC is not good as any other popular language.

You will find there is a lot library author abandoned they projects in last decade, people just leave after invest a lot time and resource.

August 03, 2021

On Tuesday, 3 August 2021 at 05:36:12 UTC, workman wrote:

>

The D language claim support NOGC Programming, but there is no ecosystem for this. It force people to use GC if they want use library.

That's just not true. The language does not force you to use the GC. But it is a language that was designed with the GC in mind, so if you want to cut it out completely then you are going to have to do some things yourself that you otherwise wouldn't have to. It's all about tradeoffs. But that's entirely your choice, just as it is for library authors who can choose to use the GC or not. The language does it force it either way.

August 03, 2021

On Sunday, 1 August 2021 at 08:54:05 UTC, Kirill wrote:

>

It's interesting to hear do you use D's GC? Or do you use your own custom memory management structure?

How performant is GC?

The reason I'm asking is I'm planning to dive into 3D game dev with D as a hobby in an attempt to create a game I dreamed of since I was a kid. I'd like to know if GC is worth using at all, or should I go with 100% manual memory management.

Any opinion is appreciated. Thanks in advance.

The D garbage collector seems reasonable for applications with small (object sized) allocations. But that changes when you allocate large blocks of memory: due to a bug internal to the tracking of allocated pages, performance gradually degrades over time. So if you have to allocate large(ish) buffers regularly, it'll show over time. I reported that bug here with a repro case, but it didn't get any attention yet:

https://issues.dlang.org/show_bug.cgi?id=20434

I haven't managed to understand thag part of the GC enough to submit a patch myself :(.

August 03, 2021

On Tuesday, 3 August 2021 at 05:36:12 UTC, workman wrote:

>

On Sunday, 1 August 2021 at 08:54:05 UTC, Kirill wrote:

>

It's interesting to hear do you use D's GC? Or do you use your own custom memory management structure?

How performant is GC?

The reason I'm asking is I'm planning to dive into 3D game dev with D as a hobby in an attempt to create a game I dreamed of since I was a kid. I'd like to know if GC is worth using at all, or should I go with 100% manual memory management.

Any opinion is appreciated. Thanks in advance.

The D language claim support NOGC Programming, but there is no ecosystem for this. It force people to use GC if they want use library.

D GC is not good as any other popular language.

You will find there is a lot library author abandoned they projects in last decade, people just leave after invest a lot time and resource.

WHY DO YOU LIE?!

there is a strong ecosystem for system libraries and nogc libraries in D

and you can plug in what ever C libraries you want, so you already can consume the WHOLE C ecosystem, out of the box

saying there is no ecosystem is plain and simple dishonest and a PURE LIE