On Mon, Oct 26, 2015 at 12:24 PM, Daniel <danlrobertson89@gmail.com> wrote:
However, if make_shared is used and we're working with a single block,
if we're also using weak_ptrs, if I'm correct the object will be destroyed
once the last strong ref is deleted, but will not be deallocated until the
last weak ref is deleted. I haven't seen many uses of weak_ptrs in LO, but
if we have code using weak refs that could outlive all of the strong
refs depending on your goals it could be better to stick with new + the
shared_ptr constructor.
Interesting point Daniel. Your point is relevant for large objects for
which weak_ptrs significantly outlive the shared_ptrs.
In that case there will be retention of the objects' memory beyond what is
strictly necessary.
We should take this point into account, but for a start the small
allocations are almost certainly to benefit from make_shared.
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.