Files
XCEngine/docs/api/XCEngine/Memory/MemoryManager/CreateProxyAllocator.md

37 lines
988 B
Markdown
Raw Normal View History

2026-03-26 16:45:24 +08:00
# MemoryManager::CreateProxyAllocator
2026-03-26 18:02:29 +08:00
创建一个代理分配器。
2026-03-26 16:45:24 +08:00
```cpp
std::unique_ptr<ProxyAllocator> CreateProxyAllocator(const char* name);
```
2026-03-26 18:02:29 +08:00
## 行为说明
2026-03-26 16:45:24 +08:00
2026-03-26 18:02:29 +08:00
当前实现等价于:
2026-03-26 16:45:24 +08:00
2026-03-26 18:02:29 +08:00
```cpp
return std::make_unique<ProxyAllocator>(m_systemAllocator, name);
```
2026-03-26 16:45:24 +08:00
2026-03-26 18:02:29 +08:00
也就是说,这个工厂当前总是把“系统分配器”作为底层分配器传给 `ProxyAllocator`
2026-03-26 16:45:24 +08:00
2026-03-26 18:02:29 +08:00
## 参数
2026-03-26 16:45:24 +08:00
2026-03-26 18:02:29 +08:00
- `name` - 代理名称;当前只会把指针原样保存,不会复制内容。
## 返回值
- `std::unique_ptr<ProxyAllocator>` - 由调用方拥有的代理分配器。
## 生命周期注意事项
- 应在 [Initialize](Initialize.md) 之后调用;否则底层分配器为空,后续任何分配操作都可能触发未定义行为。
- 应在 [Shutdown](Shutdown.md) 之前销毁;否则底层系统分配器被删除后,代理内部会留下悬空指针。
2026-03-26 16:45:24 +08:00
## 相关文档
2026-03-26 18:02:29 +08:00
- [返回类型总览](MemoryManager.md)
- [Initialize](Initialize.md)
- [Shutdown](Shutdown.md)