I am trying to place ads inside my app. According to Admob Documentation I have to initialize Mobile Ads SDK
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
This causes spike in high ram usage in code.
But if i remove this line then ram usage drops & and this line of code doesn't seem to have any affect on servering ads inside the app.
Also when requesting ad from admob ram usage again spike up and causes 3-4 GC events on app startup. I believe this is memory leak.
Here's how i am requesting ad in
onCreate
method
AdRequest request = null;
if (BuildConfig.DEBUG) {
//Facebook Audience Network
List<String> testDeviceId = new ArrayList<>();
testDeviceId.add("TESTID");//Redmi Note 3
testDeviceId.add("TESTID");//Moto G 1st Gen
AdSettings.addTestDevices(testDeviceId);
//Google Ad-mob
request = new AdRequest.Builder()
.addTestDevice("TESTID")//Redmi Note 3
.addTestDevice("TESTID")//Mot G 1st Gen
.build();
} else {
request = new AdRequest.Builder()
.build();
}
AdView mAdView = findViewById(R.id.adView);
mAdView.loadAd(request);
When loading this banner ads several GC event are kicked in. If i don't load ads GC event are never kicked in.
Is this behavior normal with admob? How can i resolve this?