OSNews article about C++09 degenerates into C++ vs. D discussion

Steve Horne stephenwantshornenospam100 at aol.com
Thu Nov 23 14:27:00 PST 2006


On Mon, 20 Nov 2006 20:37:11 +1100, Jeff
<jeffrparsons at optusnet.com.au> wrote:

>> Indeed.  The people who really need to be GC-free are a tiny minority. 
>> Wasting a lot of manpower creating a non-GC library just people who 
>> don't want to convert from C++ will have one less justification for not 
>> using D sees like a huge waste of effort to me.
>
>What about game developers? At least with the current GC, although use 
>of malloc/free isn't strictly deterministic, aren't you far less likely 
>to end up with huge (by game standards, and hence unacceptable) pauses 
>to execution? Preallocation of everything isn't always possible.

You do the allocation/deallocation at times when you can afford the
pauses, such as between levels. But then, sometimes there are no such
times.

I've never seen the source of the GTA games, of course, but here is
some reasoning based on playing them...

Consider Vice City. When crossing from one side of the map to another,
you get a delay for loading etc.

Now consider San Andreas - a much larger game that avoids those
delays. But if you drive fast enough in San Andreas, you can outrun
the loading for LOD and textures, and can end up driving through
low-detail scenery and crashing into things you can't see.

That is, San Andreas basically has (1) a high priority thread for
rendering and up-to-the-millisecond game logic, and (2) a low prioriy
thread that lags behind, loading new scenery using left-over time.

Thread (1) must read dynamically allocated memory - after all, the
scenery that is loaded must get rendered - but I doubt that it
dynamically allocates or frees any memory at all for itself.

Thread (2) could use GC or malloc/free. Either way, it has essentially
the same issue. It is designed as a slow process that doesn't need to
keep bang up to date, and so in some situations it may lag.

Thread 1 cannot afford to do dynamic allocation and freeing. Thread 2
could use either GC or malloc/free and it doesn't matter. I suspect
that that's a very common pattern.

-- 
Remove 'wants' and 'nospam' from e-mail.



More information about the Digitalmars-d mailing list