Memory management 如何释放免费列表中的所有项目?

Memory management 如何释放免费列表中的所有项目?,memory-management,d,allocation,Memory Management,D,Allocation,SharedFileList有正确的方法,但我不知道如何释放FreeList的所有节点: module runnable; import std.experimental.allocator.building_blocks; import std.experimental.allocator.mallocator; import std.experimental.allocator; shared SharedFreeList!(Mallocator, 0, unbounded) heap1

SharedFileList
有正确的方法,但我不知道如何释放
FreeList
的所有节点:

module runnable;

import std.experimental.allocator.building_blocks;
import std.experimental.allocator.mallocator;
import std.experimental.allocator;

shared SharedFreeList!(Mallocator, 0, unbounded) heap1;
FreeList!(Mallocator, 0, unbounded) heap2;

shared static ~this()
{
    heap1.deallocateAll; // OK
}

static ~this()
{
    heap2.deallocateAll; // no prop deallocateAll for...
}
虽然这个例子毫无意义,但我可能希望在类析构函数中也这样做。对于某些静态参数,
FreeList.deallocateAll
似乎已停用,但是必须有一种方法来解除列表中所有节点的分配,对吗?

根据:

仅当ParentAllocator定义deallocateAll时定义。如果是,则转发给它并重置自由列表

您使用的
Mallocator
没有
deallocateAll
,因此无法使用它。但是
SharedFileList
有自己的
deallocateAll
实现


因此,我可能会在上创建一个问题。因为我相信同样的方法也可以用于
FreeList

我没有研究
FreeList
的实现,但它可能只跟踪自由对象,而不跟踪任何已分配的对象。在这种情况下,不可能实现
deallocateAll