Generally no, there is no limit because the shared_ptr implementations on common OS's do not use mutexes under the hood (they use atomic increment/decrement functions). Also, an implementation could, for example, choose to manage all reference count accesses with a single mutex. Might be slow in some cases, but it could work.
Maximum number of std::shared_ptr managed objects per process
-
29-06-2023 - |
Question
Is there a limit in the maximum number of std::shared_ptr
managed objects per process?
Asking this because there is a maximum number of mutexes per process.
If the implementation of std::shared_ptr
is using mutex, isn't there a similar limit in the number of objects managed objects?
An answer discussing mutex-based and atomic-operation-base implementations is more than welcome.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow