[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 04:41:01 PST 2016


https://issues.dlang.org/show_bug.cgi?id=16824

--- Comment #2 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to Andrei Alexandrescu from comment #1)
> OK, so what we have here at the core is this:
> 
>     auto ints2d = allocator.makeArray!(int[])(2);
>     foreach(ref ints1d; ints2d)
>         ints1d = allocator.makeArray!(int)(3);
> 
> What I see here by means of manual coding: 
> 
> * Create an array of int[] using an allocator
> * Create a bunch of arrays of int using the same allocator
> 
> This is again by means of manual coding. The individual arrays might have
> been created using a different allocator, or sliced from a larger buffer.
> 
> I don't think we should expect the top-level allocator to "know" (assume
> really) that everything was allocated with the same allocator.

Thing would be great if we could test to see if the inner arrays were allocated
using the same allocator. If that is the case, then we can free the initial
array
entirely, otherwise it's the user's job to do that. Unfortunately, I do not
know
at this point if such a test is possible, but I will investigate further.

--


More information about the Digitalmars-d-bugs mailing list