Currently, std.experimental.allocator.building_blocks.StatsCollector does not forward to the parent allocator, but instead, makes an assumption based on the `bytesUsed` option.
`empty` is not the StatsCollector's decision to make, since the parent allocator might have a different logic based on empty, than just matching allocations with deallocations.
Please see the example below; adding the unittest in stats_collector.d will trigger the assert
```
@system unittest
{
import std.experimental.allocator.mallocator : Mallocator;
import std.typecons : Ternary;
static struct MyAlloc
{
pure nothrow @safe @nogc
Ternary empty()
{
return Ternary.no;
}
enum uint alignment = platformAlignment;
void[] allocate(size_t n) { return Mallocator.instance.allocate(n); }
bool deallocate(void[] b) { return Mallocator.instance.deallocate(b); }
static MyAlloc instance;
}
StatsCollector!(MyAlloc, Options.all) a;
auto buf = a.allocate(42);
a.deallocate(buf);
assert(a.empty == Ternary.no); // fails
}
```
Comment #1 by robert.schadek — 2024-12-01T16:33:32Z