Admob Integration on iPhone - Memory Leak Problem
I wonder if anyone can help with the following. I have integrated both iAds and AdMob into my app. However a user reported that the app crashes on the iPod Touch. Using Instruments in xCode I have managed to identify that something called "GOOGLE_SHUFFLE_RVS_User_waylonis_Code_afma1_googlmac_iPhone_GoogleAds_Signals_Protected_build_GoogleAdsSignals_build_Release_iphoneos_Google" is causing a memory leak of about 500 bytes everytime it is called.My ad refresh rate is set at 20 seconds so this happens every 20 seconds.
My code is as follows.
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// banner is visible and we move it out of the screen, due to connection issue
banner.frame = CGRectOffset(banner.frame, 0, -90);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
[self loadAdMobAd];
}
-(void)loadAdMobAd {
if (!bannerView_) {
CGRe开发者_开发技巧ct adSize = CGRectMake (0,40,0,0);
adSize.size = GAD_SIZE_320x50;
bannerView_ = [[GADBannerView alloc] initWithFrame:adSize];
bannerView_.rootViewController = self;
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
}
}
The idea is that if an iAd is not available an AdMob ad is loaded instead.
Is there anything wrong with my code that could be causing the leak ?
Many thanks,
Martin
Apparently the GOOGLE_SHUFFLE_RVS memory leak is a known issue. According to the Google Group (http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/2631fcb87d909bfa/edafd2a4ac175f47?lnk=gst&q=memory+leak#edafd2a4ac175f47), "it's a known glitch, and it'll be fixed in the next release" (from a comment posted on March 31). They also say it's fixed internally but not released yet.
I was very surprised that AdMob/Google didn't give higher priority to something as significant as an ad banner that leaks memory every time an ad loads. I guess everyone is just using the memory leaking version for now. :-o
Joe
You're alloc'ing bannerView_, adding it to the view, but not releasing it.
Try adding [bannerView_ release];
after the loadRequest line.
精彩评论