[Issue 16824] std.experimental.allocator.dispose leaks memory for arrays of more than 1 dimension
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Dec 22 05:29:40 PST 2016
https://issues.dlang.org/show_bug.cgi?id=16824
--- Comment #3 from Andrei Alexandrescu <andrei at erdani.com> ---
The owns() method allows allocators to figure that out, but returns true for
internal pointers as well, which means the following would not end well:
auto ints2d = allocator.makeArray!(int[])(2);
auto bulk = allocator.makeArray!(int[])(ints2d.length * 100);
foreach(i; 0 .. ints2d.length)
ints2s[i] = bulk[i * 100 .. (i + 1) * 100];
which is a customary way to save on allocations in multidimensional arrays.
@Atila, any good argument on how we can make this work? If not, I think we
should close as invalid.
--
More information about the Digitalmars-d-bugs
mailing list