Skip to content

Commit

Permalink
Fixed memory leak. Needs to be tested.
Browse files Browse the repository at this point in the history
  • Loading branch information
shannah committed Oct 21, 2015
1 parent 147ca9c commit 01b6ade
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions native/ios/com_codename1_admob_AdMobNativeImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ -(void)init:(NSString*)param{
id del = self;

[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
if (interstitial_ != nil) {
#ifndef CN1_USE_ARC
[interstitial_ release];
#endif
}
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID = adID;
interstitial_.delegate = del;
Expand Down Expand Up @@ -42,6 +47,11 @@ -(BOOL)loadAd{
NSLog(@"inside native startLoadingAd");
id del = self;
[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
if (interstitial_ != nil) {
#ifndef CN1_USE_ARC
[interstitial_ release];
#endif
}
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID = adID;
interstitial_.delegate = del;
Expand Down Expand Up @@ -105,5 +115,11 @@ - (void)interstitialWillLeaveApplication:(GADInterstitial *)ad {
com_codename1_admob_Callback_onAdLeftApplication__(CN1_THREAD_GET_STATE_PASS_SINGLE_ARG);
}

-(void)dealloc {
#ifndef CN1_USE_ARC
[interstitial_ release];
[super dealloc];
#endif
}

@end

0 comments on commit 01b6ade

Please sign in to comment.