Manual Memory Management Example for dlang.org Docs (Code Review)

Mike none at none.com
Wed Feb 26 16:00:17 PST 2014


On Wednesday, 26 February 2014 at 15:00:13 UTC, Dicebot wrote:
> On Wednesday, 26 February 2014 at 04:43:30 UTC, Mike wrote:
>> Please review this (http://dpaste.dzfl.pl/2377217c7870) 
>> instead.
>
>> throw new Exception("Out of memory");
>
> I don't think it is a good thing to do. Of course GC is likely 
> to have some memory left in hs internal pools but in general 
> once you hit out-of-memory state last thing you want is not 
> allocate even more.
>
>> // Deallocate test
>> heapDeallocate(test);
>
> More idiomatic D is to put `scope(exit) heapDeallocate(test);` 
> immediately after allocation line.

Thanks,

I've made changes and I guess this is the one I'll use for the 
pull.
(http://dpaste.dzfl.pl/31367860c005)


More information about the Digitalmars-d mailing list