--
I did a brief check on the places that call scoped_refptr::release in chrome main projects on Linux. Quite a few of them have possible leaks and some others is not necessary. Of course there are cases that uses it properly, i.e. call Release on the result pointer after using it.I am going to start a CL (or CLs) to remove the possible leaks and unnecessary use of release. Then we can have a better idea on how much work is left if we decide to remove it.
Before someone says "A needless AddRef() is super inefficient and I'm
going to die", I suggest we just remove the function and let people
prove that the cost is too much to bear. Most likely 99% of uses are
so seldom that the cost isn't unbearable (after all, ref-counting code
is generally one of the first things systems optimize, right up there
with the malloc library), and the last 1% can be worked around in an
alternative fashion.
-scott
+1 for removing. It's confusing too that release() does not do a Release().
On Wed, Dec 5, 2012 at 1:50 PM, Scott Hess <sh...@chromium.org> wrote:
Before someone says "A needless AddRef() is super inefficient and I'm
going to die", I suggest we just remove the function and let people
prove that the cost is too much to bear. Most likely 99% of uses are
so seldom that the cost isn't unbearable (after all, ref-counting code
is generally one of the first things systems optimize, right up there
with the malloc library), and the last 1% can be worked around in an
alternative fashion.
-scotthttps://codereview.chromium.org/11458003 (patch 1) is what I intend to land (patch 2 contains another fix, needed for trybots), modulo other uses I didn't catch in my local build. There's not that many users, and at least a couple seem to be leaking (one in tests, and one in prod). The other uses are IMO more readable now (since we have an explicit AddRef/Release pair). I will land it piecemeal.
On Wed, Dec 5, 2012 at 2:50 PM, Antoine Labour <pi...@google.com> wrote:
On Wed, Dec 5, 2012 at 1:50 PM, Scott Hess <sh...@chromium.org> wrote:
Before someone says "A needless AddRef() is super inefficient and I'm
going to die", I suggest we just remove the function and let people
prove that the cost is too much to bear. Most likely 99% of uses are
so seldom that the cost isn't unbearable (after all, ref-counting code
is generally one of the first things systems optimize, right up there
with the malloc library), and the last 1% can be worked around in an
alternative fashion.
-scotthttps://codereview.chromium.org/11458003 (patch 1) is what I intend to land (patch 2 contains another fix, needed for trybots), modulo other uses I didn't catch in my local build. There's not that many users, and at least a couple seem to be leaking (one in tests, and one in prod). The other uses are IMO more readable now (since we have an explicit AddRef/Release pair). I will land it piecemeal.As of r171893, scoped_refptr<T>::release() is no more.