Activity leak from com.google.android.gms.ads.internal.request.m.b

1,616 views
Skip to first unread message

mmccl...@twobitlabs.com

unread,
Jul 24, 2015, 6:59:08 PM7/24/15
to Google Mobile Ads SDK Developers
Using LeakCanary, I've found what appears to be an Activity leak. It occurs consistently on a Samsung Galaxy S5 running Android Version: 5.0 API: 21. (It does NOT occur on a Genymotion emulator image of a Samsung Galaxy S3 running Android 4.3 API 18.)

For this test case, I created a GoogleAdTestHarnessActivity. The ad is created when the Activity is created, and it is cleaned up in the Activity's onDestroy() method. However, every time I back out of the GoogleAdTestHarnessActivity, I get a leak report from LeakCanary.

I wondered if it might be a false alarm, if perhaps the ad view takes a while to clean up, but adding a 10-second delay and a call to System.gc() to the cleanup code had no effect.

LeakCanary version 1.3.1
Play Services 7.5.0:

Leak reference chain from the LeakCanary dump:

* com.foo.application.activities.GoogleAdTestHarnessActivity has leaked:
* GC ROOT com.google.android.gms.ads.internal.request.q.a
* references com.google.android.gms.ads.internal.request.m.b
* leaks com.foo.application.activities.GoogleAdTestHarnessActivity instance


Heap details for q and m:

* Instance of com.google.android.gms.ads.internal.request.q
|   a = com.google.android.gms.ads.internal.request.m [id=0x13845300]
|   mDescriptor = java.lang.String [id=0x12ecf0e0]
|   mOwner = com.google.android.gms.ads.internal.request.q [id=0x12fbf260]
|   mObject = -1405107656
* Instance of com.google.android.gms.ads.internal.request.m
|   a = com.google.android.gms.ads.internal.request.n [id=0x1369c260]
|   b = com.foo.application.activities.GoogleAdTestHarnessActivity [id=0x12f7e880]
|   c = com.google.android.gms.ads.internal.request.AdRequestInfoParcel [id=0x135606a0]
|   d = com.google.android.gms.ads.internal.request.c [id=0x13824340]
|   e = java.lang.Object [id=0x13961ad0]
|   a = com.google.android.gms.ads.internal.request.AdRequestInfoParcel [id=0x135606a0]
|   b = com.google.android.gms.ads.internal.request.c [id=0x13824340]
|   c = java.lang.Object [id=0x13961ac0]
|   d = com.google.android.gms.ads.internal.request.AdResponseParcel [id=0x1368c500]
|   i = com.google.android.gms.ads.internal.util.b [id=0x13961ab0]
|   j = java.lang.Thread [id=0x13a450a0]


This is the code used to create the PublisherAdView and load the ad:

mAdView = new PublisherAdView(this);
mAdView.setClipChildren(true);
String adUnitId = "<removed>";
mAdView.setAdUnitId(adUnitId);
mAdView.setAdSizes(AdSize.BANNER);
ViewGroup.LayoutParams adLayout = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mAdView.setLayoutParams(adLayout);

PublisherAdRequest.Builder adRequestBuilder = new PublisherAdRequest.Builder();
adsLayout = (ViewGroup) findViewById(R.id.debug_ads_layout);
adsLayout.addView(mAdView);
mAdView.loadAd(adRequestBuilder.build());


And this is the cleanup code called from within the Activity's onDestroy() method.

mAdView.pause();
mAdView.destroy();
adsLayout.removeAllViews();

Thomas Barthélémy

unread,
Jul 27, 2015, 10:51:34 PM7/27/15
to Google Mobile Ads SDK Developers, mmccl...@twobitlabs.com

Hi,


Same leak seems to occur consistently on Nexus 5 as well, using both AdView or PublisherAdView :(


Waiting forward to reading from dev team.


Play Services 7.5.0


In com.removed:1.2.4:1.
* removed.Activity has leaked:


* GC ROOT com.google.android.gms.ads.internal.request.q.a
* references com.google.android.gms.ads.internal.request.m.b

* leaks removed.Activity  instance

* Reference Key: 0ff598c3-885d-45b5-a9a7-1a2b358e5429
* Device: LGE google Nexus 5 hammerhead
* Android Version: 5.1 API: 22 LeakCanary: 1.3.1
* Durations: watch=5018ms, gc=225ms, heap dump=9844ms, analysis=27696ms


* Details:
* Instance of com.google.android.gms.ads.internal.request.q
|   a = com.google.android.gms.ads.internal.request.m [id=0x13bfa880]
|   mDescriptor = java.lang.String [id=0x12daf0e0]
|   mObject = -1361419888
|   mOwner = com.google.android.gms.ads.internal.request.q [id=0x13cc7040]
* Instance of com.google.android.gms.ads.internal.request.m
|   a = com.google.android.gms.ads.internal.request.n [id=0x13204dc0]
|   b = removed.Activity  [id=0x12e94180]
|   c = com.google.android.gms.ads.internal.request.AdRequestInfoParcel [id=0x133a93d0]
|   d = com.google.android.gms.ads.internal.request.c [id=0x13bd07c0]
|   e = java.lang.Object [id=0x13015bd0]
|   a = com.google.android.gms.ads.internal.request.AdRequestInfoParcel [id=0x133a93d0]
|   b = com.google.android.gms.ads.internal.request.c [id=0x13bd07c0]
|   c = java.lang.Object [id=0x13015bb0]
|   d = com.google.android.gms.ads.internal.request.AdResponseParcel [id=0x13302180]
|   i = com.google.android.gms.ads.internal.util.b [id=0x13015ba0]
|   j = java.lang.Thread [id=0x13627f40]

Misha Galian

unread,
Jul 29, 2015, 4:52:18 AM7/29/15
to Google Mobile Ads SDK Developers, mmccl...@twobitlabs.com
Hello! we have the same problem!

thom...@netcosports.com

unread,
Jul 29, 2015, 5:11:58 AM7/29/15
to Google Mobile Ads SDK Developers, mmccl...@twobitlabs.com
Using 

new PublisherAdView(context.getApplicationContext());

avoid leak on activity but it's only a work around, doesn't solve the problem :x



Le samedi 25 juillet 2015 00:59:08 UTC+2, mmccl...@twobitlabs.com a écrit :

Tristan Emrich

unread,
Aug 4, 2015, 7:56:36 PM8/4/15
to Google Mobile Ads SDK Developers, mmccl...@twobitlabs.com
The memory leak issue was fixed in the latest release of Google Play Services (v7.8).  In order to resolve the issue, you will need to update Google Play Services to version 7.8 on your mobile device.  

Thank you!

Tristan

Kevin Zheng

unread,
Aug 7, 2015, 1:11:03 AM8/7/15
to Google Mobile Ads SDK Developers, mmccl...@twobitlabs.com
Hi Tristan,

I am experiencing a similar issue. I am using PublisherAdView and current Google Play Services version has already been 7.8.95 on the device. Which Google Play Services version should I use in my Gradle? Here is my LeakCanary output
 
* au.com.kevin.activities.MainActivity has leaked:
* GC ROOT android.os.Handler$MessengerImpl.this$0
* references com.google.android.gms.ads.internal.n.l.a
* references com.google.android.gms.ads.internal.n.m.a
* leaks au.com.kevin.activities. MainActivity instance

Kevin

Jens Driller

unread,
Aug 7, 2015, 12:26:44 PM8/7/15
to Google Mobile Ads SDK Developers, mmccl...@twobitlabs.com
I can confirm that the leak Kevin posted still occurs even with the latest v7.8.95 of Google Play Services.

Tristan Emrich

unread,
Aug 7, 2015, 6:27:33 PM8/7/15
to Google Mobile Ads SDK Developers, mmccl...@twobitlabs.com
I went ahead and filed a bug for this issue.  The engineering team is looking into it and will hopefully have a solution soon.

Thank you for your patience!
Tristan

Tristan Emrich

unread,
Aug 25, 2015, 2:48:39 PM8/25/15
to Google Mobile Ads SDK Developers, mmccl...@twobitlabs.com
The bug(memory leak issue) has been fixed and the changes will go out in the next release of the Google Mobile Ads SDK.  

Thank you again for everyone's patience.

Tristan

thom...@netcosports.com

unread,
Aug 26, 2015, 2:28:23 AM8/26/15
to Google Mobile Ads SDK Developers, mmccl...@twobitlabs.com
Thank you (=
Reply all
Reply to author
Forward
Message has been deleted
0 new messages