digitalmars.D - How do I use the ScopedAllocator?
- Yuxuan Shui (25/25) Jul 21 2016 Is it OK to use makeArray with ScopedAllocator to allocate
- Nick Treleaven (4/6) Jul 24 2016 I noticed (using dpaste) if you edit the 'b' line to only
- Yuxuan Shui (3/9) Jul 25 2016 Valgrind reports double free anyways. I think it's just the
- Nick Treleaven (5/7) Jul 28 2016 Please file a bug - thanks!
- Yuxuan Shui (2/9) Aug 02 2016 Fix: https://github.com/dlang/phobos/pull/4702
Is it OK to use makeArray with ScopedAllocator to allocate something with a destructor? Because the destructor is not called when ScopedAllocator goes out of scope. And if I manually call dispose, I get a double free error: struct A { int a; ~this() nothrow { } } void test(){ import std.experimental.allocator.mallocator : Mallocator; import std.experimental.allocator.building_blocks.scoped_allocator : ScopedAllocator; import std.experimental.allocator; ScopedAllocator!Mallocator alloc; auto b = alloc.makeArray!A(10, A(1)); auto c = alloc.makeArray!A(2, A(2)); alloc.dispose(b); alloc.dispose(c); } void main() { test(); }
Jul 21 2016
On Friday, 22 July 2016 at 01:54:28 UTC, Yuxuan Shui wrote:auto b = alloc.makeArray!A(10, A(1)); auto c = alloc.makeArray!A(2, A(2));I noticed (using dpaste) if you edit the 'b' line to only allocate 5 structs, and it won't crash. 6 or more, crash. Maybe a bug?
Jul 24 2016
On Sunday, 24 July 2016 at 20:48:55 UTC, Nick Treleaven wrote:On Friday, 22 July 2016 at 01:54:28 UTC, Yuxuan Shui wrote:Valgrind reports double free anyways. I think it's just the inaccuracy of the glibc double free detection.auto b = alloc.makeArray!A(10, A(1)); auto c = alloc.makeArray!A(2, A(2));I noticed (using dpaste) if you edit the 'b' line to only allocate 5 structs, and it won't crash. 6 or more, crash. Maybe a bug?
Jul 25 2016
On Monday, 25 July 2016 at 07:33:25 UTC, Yuxuan Shui wrote:Valgrind reports double free anyways. I think it's just the inaccuracy of the glibc double free detection.Please file a bug - thanks! https://issues.dlang.org/ I found this, maybe related: https://issues.dlang.org/show_bug.cgi?id=16046
Jul 28 2016
On Thursday, 28 July 2016 at 11:48:40 UTC, Nick Treleaven wrote:On Monday, 25 July 2016 at 07:33:25 UTC, Yuxuan Shui wrote:Fix: https://github.com/dlang/phobos/pull/4702Valgrind reports double free anyways. I think it's just the inaccuracy of the glibc double free detection.Please file a bug - thanks! https://issues.dlang.org/ I found this, maybe related: https://issues.dlang.org/show_bug.cgi?id=16046
Aug 02 2016