30 lines
632 B
Markdown
30 lines
632 B
Markdown
|
|
# LinearAllocator::~LinearAllocator
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
~LinearAllocator() override;
|
||
|
|
```
|
||
|
|
|
||
|
|
销毁线性分配器,释放预分配的缓冲区。如果提供了 `parent` 分配器,则使用它释放缓冲区;否则使用系统默认释放(`::operator delete`)。
|
||
|
|
|
||
|
|
**参数:** 无
|
||
|
|
|
||
|
|
**返回:** 无
|
||
|
|
|
||
|
|
**复杂度:** O(1)
|
||
|
|
|
||
|
|
**示例:**
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
#include <XCEngine/Memory/LinearAllocator.h>
|
||
|
|
|
||
|
|
{
|
||
|
|
LinearAllocator allocator(1024 * 1024);
|
||
|
|
void* ptr = allocator.Allocate(256);
|
||
|
|
// ... 使用 allocator
|
||
|
|
} // 析构时自动释放 1MB 缓冲区
|
||
|
|
```
|
||
|
|
|
||
|
|
## 相关文档
|
||
|
|
|
||
|
|
- [LinearAllocator 总览](linear-allocator.md) - 返回类总览
|