How do you deal with scoped allocations?

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Dec 8 04:29:15 PST 2013


08-Dec-2013 13:25, Namespace пишет:
> On Sunday, 8 December 2013 at 09:14:44 UTC, Dmitry Olshansky wrote:
>> 08-Dec-2013 02:32, Namespace пишет:
[snip]
>>>
>>> And what do you use?
>
> Because it's more D'ish.

There is no such objective quality as being D'ish.
GC.malloc/GC.free are no better then malloc/free in code style, 
readability or observable effect.

 > That is what D offers.
D offers you C run-time as well. In fact it builds on top of it.
See also (hopefully) soon to be formally reviewed std.allocator.

> Why is it slower than malloc + free?

1. Because GC.minimize does a hell of a work to optimize the whole GC 
heap. For starters it does collection so as to get rid of floating 
garbage (AFAIK).

2. You have a trivial use case of deterministic allocation - you know 
precisely when to deallocate a block. In this setting putting allocated 
block into tracing GC heap is a waste of time should a collection happen.

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list