What can you "new"

Daniel Keep daniel.keep.lists at gmail.com
Wed Mar 25 04:43:46 PDT 2009



Cristian Vlasceanu wrote:
>>> Do custom-allocated objects live on the GC-ed heap?
>> Not necessarily, e.g. you can malloc some memory and then create an object 
>> there.
>>
> 
> I was afraid that may be the case, and it is perhaps not a good idea.
> 
> ...
> 
> This is why D .net does not support any of this custom allocator nonsense.
> 
> 
> My two Global-Currency / 100
> 
> Cristi

It's funny, but I was recently doing some game prototyping and needed a
very fast, garbage-free way of allocating lots of small, short-lived
objects.

I thought "Ha! I have a block allocator mixin for just this purpose!"
...until I remembered I was programming in C# and not D.

So now I have to create an array of pre-allocated objects, and have a
protocol for assigning and returning them.  Plus, I have to have a
unique pool for each subclass since I can't use casts to override the
type system.

Urgh.

  -- Daniel



More information about the Digitalmars-d mailing list