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.
Is there a way to specify custom allocator for an 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
). It does its job based on allocations which are part of any shared_ptr
's control block. You can customize shared_ptr
's control block allocation behavior, but that's got nothing to do with weak_ptr
itself.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.