924 B
924 B
ProxyAllocator::Free
通过底层分配器释放内存,并更新代理统计。
void Free(void* ptr) override;
行为说明
当前实现会先加锁,然后执行:
- 调用
m_underlying->Free(ptr)。 - 执行
m_stats.totalFreed += m_stats.allocationCount。 - 执行
m_stats.allocationCount--。
参数
ptr- 要释放的指针。
返回值
- 无。
当前实现限制
totalFreed增加的是“当前 allocation count”,不是被释放块的真实字节数。- 如果
allocationCount当前为0,执行m_stats.allocationCount--会发生无符号下溢。 ptr是否允许为nullptr,取决于底层分配器;代理层没有额外保护。- 如果
m_underlying == nullptr,当前实现会直接解引用空指针。