3 ms·
And if the array is heap allocated.
by Skinney 5y ago
And if the array is heap allocated.
- yakubin 5y agoIf the array is stack-allocated and the elements are boxed (i.e. heap-allocated) or have destructors, you are still going to need to call the destructors or the free on the elements when the array goes out of scope.
- ncmncm 5y agoSuch a layout, and all it costs, is typically unavoidable in GC languages, and usually easily avoided in non-GC languages, particularly in cases where it would matter. Thus, it is incorrect to talk about multiple calls to a deallocator. You get just one for the whole array.
- Skinney 5y agoMy point was: it still takes longer time to de-allocate a large array even if the only thing that needs to be freed is the array itself, when compared to a GC. GC never needs to free anything, it instead overwrites garbage memory with live memory.