|
|
|
|
|
by vlovich123
479 days ago
|
|
So for example, if I do: static std::weak_ptr<std::array<uint64_t, 125000000>> weak;
std::shared_ptr<std::array<uint64_t, 125000000>> strong = std::make_shared({0});
weak = std::weak_ptr(strong);
That retains 1GiB of memory allocated without any ownership path due to implementation details of std::shared_ptr. Is that a memory leak? There’s no active thread that has a path and yet all of the memory is tracked - if you destroy the weak_ptr thee 1GiB of memory gets reclaimed. |
|