docs: rebuild Memory API content
This commit is contained in:
@@ -1,31 +1,36 @@
|
||||
# MemoryManager::CreateProxyAllocator
|
||||
|
||||
创建新对象或资源。
|
||||
创建一个代理分配器。
|
||||
|
||||
```cpp
|
||||
std::unique_ptr<ProxyAllocator> CreateProxyAllocator(const char* name);
|
||||
```
|
||||
|
||||
该方法声明于 `XCEngine/Memory/MemoryManager.h`,当前页面用于固定 `MemoryManager` 类目录下的方法级 canonical 路径。
|
||||
## 行为说明
|
||||
|
||||
**参数:**
|
||||
- `name` - 参数语义详见头文件声明。
|
||||
|
||||
**返回:** `std::unique_ptr<ProxyAllocator>` - 返回值语义详见头文件声明。
|
||||
|
||||
**示例:**
|
||||
当前实现等价于:
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/MemoryManager.h>
|
||||
|
||||
void Example() {
|
||||
XCEngine::Memory::MemoryManager object;
|
||||
// 根据上下文补齐参数后调用 MemoryManager::CreateProxyAllocator(...)。
|
||||
(void)object;
|
||||
}
|
||||
return std::make_unique<ProxyAllocator>(m_systemAllocator, name);
|
||||
```
|
||||
|
||||
也就是说,这个工厂当前总是把“系统分配器”作为底层分配器传给 `ProxyAllocator`。
|
||||
|
||||
## 参数
|
||||
|
||||
- `name` - 代理名称;当前只会把指针原样保存,不会复制内容。
|
||||
|
||||
## 返回值
|
||||
|
||||
- `std::unique_ptr<ProxyAllocator>` - 由调用方拥有的代理分配器。
|
||||
|
||||
## 生命周期注意事项
|
||||
|
||||
- 应在 [Initialize](Initialize.md) 之后调用;否则底层分配器为空,后续任何分配操作都可能触发未定义行为。
|
||||
- 应在 [Shutdown](Shutdown.md) 之前销毁;否则底层系统分配器被删除后,代理内部会留下悬空指针。
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [返回类总览](MemoryManager.md)
|
||||
- [返回模块目录](../Memory.md)
|
||||
- [返回类型总览](MemoryManager.md)
|
||||
- [Initialize](Initialize.md)
|
||||
- [Shutdown](Shutdown.md)
|
||||
|
||||
Reference in New Issue
Block a user