-
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛] Memory Leak Issue with react-native-google-mobile-ads Library #496
Comments
Haven't noticed this in our demo app. |
I have the same issue. Memory and CPU leak leads to the app crashing after navigating to multiple screens (displaying a banner) back and forth. When I remove the banner, the issue vanishes. I use react-navigation and I notice the issue on iOS. I didn't try on Android. |
Please test if #508 fixes it. |
Sorry I do not think it fixes it. |
@Vukasin2212 does the PR solve the memory leaks? |
It seems to fix the issue on iOS release mode. |
🎉 This issue has been resolved in version 12.7.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thank you, I will check and then provide feedback. |
The lag problem has increased on the iOS side. I use latest version (v12.10.0). The app slows down, gets hot and crashes. iOS side is fine in older versions. Can you check this problem @mikehardy. Regards |
No I can't sorry, no available volunteer time to profile things for other people. You can use the xcode profiler I believe? |
I also encountered the same problem. There is a event handler added in recent updates. I think this is due to the event handler. When I remove that event handler, the problem is solved. Could it be related to this? @mikehardy remove this event handler in RNGoogleMobileAdsBannerView.mm
And removed this method in RNGoogleMobileAdsFullScreenAd.swift
}; (ad as? GADRewardedAd)?.paidEventHandler = paidEventHandler; |
Tagging @birdofpreyru here who built the feature. |
It reads like my additions to iOS code to support impression-level ad revenue events introduced a circular dependency between objects allocated in memory, preventing the garbage collector to drop them. @sedatb have you checked that removing both of these handlers is necessary, or just removing the second of them is enough? |
Hi @birdofpreyru, |
Could you provide a demo which demonstrates the lag? |
well... @dylancom @sedatb here is what I got... The following handler is only relevant to iOS / New RN Arch. No matter whether I comment it or not, the banner views seem to never deallocate (checked by adding a log message to the dealloc() method, and running the example app I never see it printing either way). Perhaps there some other strong reference cycles preventing the deallocation, or I am doing something wrong... either way can't look more into it now, as I am not yet using old arch on ios anyway in my projects. react-native-google-mobile-ads/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerView.mm Lines 119 to 126 in d438bf2
The similar handler in the iOS / Old RN Arch banners code indeed makes the difference between allowing and not allowing the banner components to deallocate (checked in the similar way mentioned above), because the mistake explained in my previous message. I've submitted PR #565 fixing it — please merge it. react-native-google-mobile-ads/ios/RNGoogleMobileAds/RNGoogleMobileAdsBannerComponent.m Lines 120 to 127 in d438bf2
For all sorts of interstitials / full screen ads I am not sure... The deinit() method does not seem to be ever called, no matter whether I comment out the handler or not... needs to be further investigated some time later. react-native-google-mobile-ads/ios/RNGoogleMobileAds/RNGoogleMobileAdsFullScreenAd.swift Lines 95 to 112 in d438bf2
|
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
Thank you for your contributions. |
Let's keep it open — I'd double-check there is no memory leak on the iOS / new arch, with the latest code version. |
What happened?
I am encountering a memory leak problem that I suspect is caused by improper destruction on the library side. When the screen with banners is not focused, I remove the banners using the following approach:
return isFocused ? ( <GAMBannerAd unitId={id} sizes={sizes} onAdFailedToLoad={onAdFailedToLoad} onAdLoaded={onAdLoaded} requestOptions={{ requestNonPersonalizedAdsOnly: true, }} /> ) : null;
The banner disappears as expected, but it seems to continue running in the background. Even when I navigate to the next page and return to the page with banners, I experience a memory leak, presumably because it endlessly creates new banners without properly destroying the old ones. I haven't noticed a capability to destroy a banner before removing it from the render. Are you familiar with this issue?
Steps to Reproduce:
Navigate to a screen with banners.
Remove the banners when the screen is not focused.
Navigate to another screen.
Return to the screen with banners.
Expected Behavior:
The banners should be properly destroyed when removed from the render, preventing any memory leaks.
Additional Information:
Any insights or guidance on resolving this issue would be greatly appreciated. Thank you!
Platforms
Android and iOS
React Native Info
Are your using Typescript?
package.json
app.json
ios/Podfile
No response
android/build.gradle
No response
android/app/build.gradle
No response
android/settings.gradle
No response
AndroidManifest.xml
No response
The text was updated successfully, but these errors were encountered: