GC vs. Manual Memory Management Real World Comparison
Benjamin Thaut
code at benjamin-thaut.de
Wed Sep 5 09:10:49 PDT 2012
Am 05.09.2012 16:57, schrieb bearophile:
> Benjamin Thaut:
>
>> http://3d.benjamin-thaut.de/?p=20#more-20
>
> Regardind your issues list, most of them are fixable, like the one
> regarding array literals, and even the one regarding the invariant handler.
>
> But I didn't know about this, and I don't know how and if this is fixable:
>
>> The new statement will not free any memory if the constructor throws a
>> exception.<
>
> Insights welcome.
>
> Bye,
> bearophile
Well, as overloading new and delete is deprecated, and the new which is
part of the language only works together with a GC I don't think that
anything will be done about this.
Its not a big problem in D because you can't create arrays of objects so
that multiple constructors will be called at the same time. (Which is
the biggest issue in c++ with exceptions and constructors). Also doe to
memory pre initialization the object will always be in a meaningfull
state, which helps with exception handling too. My replacement just
calls the constructor, and if a exception is thrown, the destructor is
called and the memory is freed, then the new statement returns null.
Works flawlessley so far.
Kind Regards
Benjamin Thaut
More information about the Digitalmars-d-announce
mailing list