Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Issue 1465113002: Fix memory leak in vcm_capturer.cc. (Closed)

Created:
5 years, 1 month ago by wangrui
Modified:
5 years ago
CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com
Base URL:
https://chromium.googlesource.com/external/webrtc.git@master
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

Fix memory leak in vcm_capturer.cc. vcm_->Release won't delete vcm_ automatically since the refcount of vcm_ will be -1 after Release call. vcm_->AddRef() should be called after vcm_ creation. BUG=webrtc:5229

Patch Set 1 #

Total comments: 1

Patch Set 2 : modify ref_count.h, init ref_count to 1 after new #

Unified diffs Side-by-side diffs Delta from patch set Stats (+7 lines, -8 lines) Patch
M webrtc/system_wrappers/include/ref_count.h View 1 1 chunk +6 lines, -6 lines 0 comments Download
M webrtc/test/vcm_capturer.cc View 1 2 chunks +1 line, -2 lines 0 comments Download

Messages

Total messages: 13 (6 generated)
wangrui
5 years, 1 month ago (2015-11-23 02:57:56 UTC) #3
pbos-webrtc
Sorry for the slow reply, a question: https://codereview.webrtc.org/1465113002/diff/1/webrtc/test/vcm_capturer.cc File webrtc/test/vcm_capturer.cc (right): https://codereview.webrtc.org/1465113002/diff/1/webrtc/test/vcm_capturer.cc#newcode37 webrtc/test/vcm_capturer.cc:37: vcm_->AddRef(); Shouldn't ...
5 years ago (2015-11-26 17:12:13 UTC) #5
wangrui
On 2015/11/26 17:12:13, pbos-webrtc wrote: > Sorry for the slow reply, a question: > > ...
5 years ago (2015-11-27 04:14:49 UTC) #6
pbos-webrtc
Sorry, that's wrong again (don't modify RefCountImpl). We shouldn't be calling AddRef or Release directly, ...
5 years ago (2015-11-27 12:43:51 UTC) #8
pbos-webrtc
On 2015/11/27 12:43:51, pbos-webrtc wrote: > Sorry, that's wrong again (don't modify RefCountImpl). > > ...
5 years ago (2015-11-27 18:01:08 UTC) #9
wangrui
On 2015/11/27 18:01:08, pbos-webrtc wrote: > On 2015/11/27 12:43:51, pbos-webrtc wrote: > > Sorry, that's ...
5 years ago (2015-12-02 09:33:51 UTC) #10
pbos-webrtc
5 years ago (2015-12-02 23:44:07 UTC) #11
On 2015/12/02 09:33:51, wangrui wrote:
> On 2015/11/27 18:01:08, pbos-webrtc wrote:
> > On 2015/11/27 12:43:51, pbos-webrtc wrote:
> > > Sorry, that's wrong again (don't modify RefCountImpl).
> > > 
> > > We shouldn't be calling AddRef or Release directly, but put the
> > > VideoCaptureModule in a rtc::scoped_refptr (that's the thing supposed to
do
> > > AddRef and Release).
> > > 
> > > It's in here: webrtc/base/scoped_ref_ptr.h
> > > 
> > > So I think you want to replace:
> > > 
> > > 44  VideoCaptureModule* vcm_;
> > > 
> > > with:
> > > 
> > > 44  rtc::scoped_refptr<VideoCaptureModule> vcm_;
> > > 
> > > Which should take care of the AddRef/Releasing for you.
> > 
> > I found out that this has wider implications (we should be returning
> > scoped_refptrs everywhere).
> > 
> > I think this is easier for me to fix, so I put up a change here:
> > https://codereview.webrtc.org/1477013005/
> > 
> > I hope this is OK with you.
> 
> Yes, I am absolutely OK with this.
> sorry for my improper patches.
> Hope i can contribute next time.

Thanks for the patch though, I'd be glad to review a future one! This one grew
larger than I thought it would. Closing this issue now, but feel free to send me
an email or so if you think you have something else and want to discuss whether
it's easy/hard.

Best,
- Peter

Powered by Google App Engine
This is Rietveld 408576698