docs: update memory and threading API docs
This commit is contained in:
33
docs/api/memory/linear-allocator/get-peak-allocated.md
Normal file
33
docs/api/memory/linear-allocator/get-peak-allocated.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# LinearAllocator::GetPeakAllocated
|
||||
|
||||
```cpp
|
||||
size_t GetPeakAllocated() const override;
|
||||
```
|
||||
|
||||
返回自分配器创建以来的峰值分配字节数。对于线性分配器,这等于总容量(`m_capacity`)。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 峰值分配字节数(等于容量)
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/LinearAllocator.h>
|
||||
|
||||
LinearAllocator allocator(1024);
|
||||
|
||||
size_t peak = allocator.GetPeakAllocated(); // 1024(容量)
|
||||
|
||||
allocator.Allocate(512);
|
||||
size_t used = allocator.GetUsedSize(); // 512
|
||||
|
||||
// 即使未达到容量,峰值仍为容量大小
|
||||
size_t peak_after = allocator.GetPeakAllocated(); // 1024
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [LinearAllocator 总览](linear-allocator.md) - 返回类总览
|
||||
Reference in New Issue
Block a user