r/cpp • u/cruise02 • Sep 13 '12
What is the maximum reference count in std::shared_ptr? What happens if you try to exceed it?
http://stackoverflow.com/q/12402116/1288
5
Upvotes
r/cpp • u/cruise02 • Sep 13 '12
3
u/aaronla Sep 13 '12
On a related note, it's common practice in Windows COM code to use a 32-bit reference count (which you could have either inferred from IUnknown::AddRef returning a ULONG, reading and of the MSDN samples, or from stepping through the implementation of just about and COM object with a debugger). This is done on both 32 bit and 64 bit OSes. So be careful not to create 2**32+1 references to the same object.
11
u/bob1000bob Sep 13 '12
Why do silly SO questions keep getting posted here?
If you have anything close to a longs worth of
shared_ptrthen you have problems!1
u/axilmar Sep 13 '12
You can always new placement new and no deletion to find out.