[英]Custom allocator for weak_ptr
From high CPU usage in RtlpLowFragHeapAllocFromContext()
I am making a guess that std::weak_ptr()
that I use frequently (calling .lock()
on it) should be the culprit that doesn't use the internal efficient memory pool, but rather resorts to malloc()
/ free()
/ new
/ delete
guys.从
RtlpLowFragHeapAllocFromContext()
中的高 CPU 使用率来看,我猜测我经常使用的std::weak_ptr()
(在其上调用.lock()
)应该是不使用内部高效 memory 池的罪魁祸首,而是诉诸malloc()
/ free()
/ new
/ delete
家伙。
Is there a way to specify custom allocator for an std::weak_ptr
?有没有办法为
std::weak_ptr
指定自定义分配器? If yes, how?如果是,如何? If no, why?
如果不是,为什么?
weak_ptr
does not allocate memory, nor do any of its operations (which are all noexcept
). weak_ptr
不分配 memory,也没有它的任何操作(都是noexcept
)。 It does its job based on allocations which are part of any shared_ptr
's control block.它基于作为任何
shared_ptr
控制块一部分的分配来完成其工作。 You can customize shared_ptr
's control block allocation behavior, but that's got nothing to do with weak_ptr
itself.您可以自定义
shared_ptr
的控制块分配行为,但这与weak_ptr
本身无关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.