Memory leak with dynamic array

Ellery Newcomer ellery-newcomer at
Sun Apr 11 18:06:18 PDT 2010

On 04/11/2010 07:42 PM, bearophile wrote:
> D dynamic arrays are more flexible than C++ vector, they can be sliced, such slicing is O(1), and the slices are seen by the language just like other arrays. So you pay the price of some performance for such increased flexibility. The idea here is that the built-in data types must be as flexible as possible even if their performance is not so high, so they can be used for many different purposes. Then D standard library will have specialized data structures that are faster thanks to being more specialized and less flexible. In D dynamic arrays some of the performance price is also paid for the automatic memory management, for the GC that's not a precise GC (for example if your array has some empty items at the end past its true length, the GC must ignore them).

OTish: It would be nice if the data-structures-to-be are designed such 
that they can be easily dropped in wherever dynamic arrays are used. At 
least the list-like ones.

More information about the Digitalmars-d-learn mailing list