Add missing destructor documentation for PoolAllocator and ProxyAllocator
- Created docs/api/memory/pool-allocator/~pool-allocator.md documenting the destructor - Created docs/api/memory/proxy-allocator/~proxy-allocator.md documenting the destructor - Added ~ProxyAllocator entry to proxy-allocator.md overview table - Verified link validation passes (no broken references)
This commit is contained in:
31
docs/api/memory/pool-allocator/~pool-allocator.md
Normal file
31
docs/api/memory/pool-allocator/~pool-allocator.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# PoolAllocator::~PoolAllocator
|
||||
|
||||
```cpp
|
||||
~PoolAllocator() override;
|
||||
```
|
||||
|
||||
销毁内存池分配器,释放预分配的所有内存块。析构函数调用 `std::free` 释放整个内存池,不再需要单独释放每个块。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**注意:** 析构函数释放整个内存池,包括所有已分配和空闲的块。调用析构函数后,池中所有已分配出去的块也随之失效,使用这些块指针将导致未定义行为。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/PoolAllocator.h>
|
||||
|
||||
{
|
||||
PoolAllocator pool(sizeof(int), 1000);
|
||||
void* block = pool.Allocate();
|
||||
// ... 使用内存块
|
||||
|
||||
pool.Free(block); // 可选:显式释放(析构时会自动释放)
|
||||
} // 超出作用域时自动释放整个内存池
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [PoolAllocator 总览](pool-allocator.md) - 返回类总览
|
||||
37
docs/api/memory/proxy-allocator/~proxy-allocator.md
Normal file
37
docs/api/memory/proxy-allocator/~proxy-allocator.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# ProxyAllocator::~ProxyAllocator
|
||||
|
||||
```cpp
|
||||
~ProxyAllocator() override;
|
||||
```
|
||||
|
||||
销毁代理分配器。此析构函数不释放底层分配器,只清理代理分配器自身的统计信息(互斥锁等)。底层分配器由创建者负责管理。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**注意:** 析构函数不释放底层分配器。如果需要释放底层分配器,应先调用 `Shutdown` 或显式销毁底层分配器。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
#include <XCEngine/Memory/ProxyAllocator.h>
|
||||
|
||||
{
|
||||
MemoryManager::Get().Initialize();
|
||||
IAllocator* sysAlloc = MemoryManager::Get().GetSystemAllocator();
|
||||
|
||||
auto proxy = MemoryManager::Get().CreateProxyAllocator("TrackedAlloc");
|
||||
proxy->Allocate(1024);
|
||||
|
||||
// proxy 超出作用域时自动销毁
|
||||
// 底层 sysAlloc 仍有效
|
||||
|
||||
MemoryManager::Get().Shutdown();
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [ProxyAllocator 总览](proxy-allocator.md) - 返回类总览
|
||||
Reference in New Issue
Block a user