docs: rebuild Memory API content
This commit is contained in:
@@ -1,32 +1,36 @@
|
||||
# MemoryManager::CreatePoolAllocator
|
||||
|
||||
创建新对象或资源。
|
||||
创建一个池分配器。
|
||||
|
||||
```cpp
|
||||
std::unique_ptr<PoolAllocator> CreatePoolAllocator(size_t blockSize, size_t count);
|
||||
```
|
||||
|
||||
该方法声明于 `XCEngine/Memory/MemoryManager.h`,当前页面用于固定 `MemoryManager` 类目录下的方法级 canonical 路径。
|
||||
## 行为说明
|
||||
|
||||
**参数:**
|
||||
- `blockSize` - 参数语义详见头文件声明。
|
||||
- `count` - 参数语义详见头文件声明。
|
||||
|
||||
**返回:** `std::unique_ptr<PoolAllocator>` - 返回值语义详见头文件声明。
|
||||
|
||||
**示例:**
|
||||
当前实现等价于:
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
void Example() {
|
||||
XCEngine::Memory::MemoryManager object;
|
||||
// 根据上下文补齐参数后调用 MemoryManager::CreatePoolAllocator(...)。
|
||||
(void)object;
|
||||
}
|
||||
return std::make_unique<PoolAllocator>(blockSize, count);
|
||||
```
|
||||
|
||||
它不会使用 `m_systemAllocator`,因此即使没有调用 [Initialize](Initialize.md) 也可以工作。
|
||||
|
||||
## 参数
|
||||
|
||||
- `blockSize` - 单个逻辑 block 大小。
|
||||
- `count` - block 数量。
|
||||
|
||||
## 返回值
|
||||
|
||||
- `std::unique_ptr<PoolAllocator>` - 由调用方拥有的池分配器。
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 这个工厂同样只是创建对象,不会集中托管其生命周期。
|
||||
- 参数不会在 `MemoryManager` 层做额外校验,`PoolAllocator` 自身当前也缺少防御式检查。
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [返回类总览](MemoryManager.md)
|
||||
- [返回模块目录](../Memory.md)
|
||||
- [返回类型总览](MemoryManager.md)
|
||||
- [Initialize](Initialize.md)
|
||||
|
||||
Reference in New Issue
Block a user