issue: After every rewarded video, or interstitial. memmory goes up, and does not go down, causing ANR's and crashes.
Tested on physical devices with test ads RV and INT, both on android and ios. Both platforms and ad types show the same issue.
Am on latest version of GM and extension (updated 1 Sept). Memory leak ads up to about 10MB per video. so ads up fast.
findings:
Me and Chatgpt, since i do not know java.... have adjusted the Java code from the extension and got the leak back about 90 percent, but not yet to 0.
what i did
Context Handling with getApplicationContext():
Change: We modified the context used in InterstitialAd.load to activity.getApplicationContext() instead of activity.
Reason: Using getApplicationContext() ensures that the interstitial ad doesn't hold a strong reference to the Activity, which can cause memory leaks if the Activity is destroyed or recreated (e.g., during a configuration change). The ApplicationContext is a singleton, so it doesn't have the same lifecycle issues as an Activity.
java
Code kopiëren
InterstitialAd.load(activity.getApplicationContext(), adUnitId, buildAdRequest(), new InterstitialAdLoadCallback() {
// ...
});
Memory Management Enhancements:
Change: Added code to clean up interstitial ad resources after they are no longer needed. This included nullifying references to InterstitialAd objects and their listeners.
Reason: To prevent memory leaks by ensuring that no unnecessary references to ad objects or listeners are kept after the ad has been shown and dismissed.
java
Code kopiëren
// In AdMob_Interstitial_Show()
interstitialAdRef.setFullScreenContentCallback(new FullScreenContentCallback() {
@Override
public void onAdDismissedFullScreenContent() {
// Cleanup after the ad is dismissed
interstitialAdRef.setFullScreenContentCallback(null);
interstitialAdRef = null;
// Further cleanup logic
}
// ...
});
Since this fixed a big part of the issue, i'm presuming something is up with the way the ad(view) gets destroyed and not cleaned up. But thats assuming since again... JAVA and android as a whole is not my cup of tea. Hence me using Gamemaker and extensions...
issue: After every rewarded video, or interstitial. memmory goes up, and does not go down, causing ANR's and crashes.
Tested on physical devices with test ads RV and INT, both on android and ios. Both platforms and ad types show the same issue. Am on latest version of GM and extension (updated 1 Sept). Memory leak ads up to about 10MB per video. so ads up fast.
findings: Me and Chatgpt, since i do not know java.... have adjusted the Java code from the extension and got the leak back about 90 percent, but not yet to 0.
what i did
Context Handling with getApplicationContext():
Change: We modified the context used in InterstitialAd.load to activity.getApplicationContext() instead of activity. Reason: Using getApplicationContext() ensures that the interstitial ad doesn't hold a strong reference to the Activity, which can cause memory leaks if the Activity is destroyed or recreated (e.g., during a configuration change). The ApplicationContext is a singleton, so it doesn't have the same lifecycle issues as an Activity. java Code kopiëren InterstitialAd.load(activity.getApplicationContext(), adUnitId, buildAdRequest(), new InterstitialAdLoadCallback() { // ... }); Memory Management Enhancements:
Change: Added code to clean up interstitial ad resources after they are no longer needed. This included nullifying references to InterstitialAd objects and their listeners. Reason: To prevent memory leaks by ensuring that no unnecessary references to ad objects or listeners are kept after the ad has been shown and dismissed. java Code kopiëren // In AdMob_Interstitial_Show() interstitialAdRef.setFullScreenContentCallback(new FullScreenContentCallback() { @Override public void onAdDismissedFullScreenContent() { // Cleanup after the ad is dismissed interstitialAdRef.setFullScreenContentCallback(null); interstitialAdRef = null; // Further cleanup logic } // ... });
Since this fixed a big part of the issue, i'm presuming something is up with the way the ad(view) gets destroyed and not cleaned up. But thats assuming since again... JAVA and android as a whole is not my cup of tea. Hence me using Gamemaker and extensions...