mazipan / vue-google-adsense

💰 Vue.js Google Adsense Component with InFeed and InArticle Ads support
https://mazipan.github.io/vue-google-adsense/
MIT License
257 stars 42 forks source link

Memory leak #73

Closed halaei closed 4 years ago

halaei commented 5 years ago

I am using InFeedAdsense and Adsense components. Using a small test to programmatically navigate between app pages with ads, I find it has memory leaks. Over time, it makes a lot of detached dom elements that can't be garbage collected. It seams every time a component is created, 2 listeners are added to window, listening to load and message events. But they are never removed. I am wondering if '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js' should be added inside html only once an not once per component?

halaei commented 5 years ago

I also guess v-else is missing here:

    <script2
      v-if="isNonPersonalizedAds"
      type="text/javascript">
      (adsbygoogle = window.adsbygoogle || []).push({}).requestNonPersonalizedAds = 1;
    </script2>
    <script2 type="text/javascript"> // v-else missing???
      (adsbygoogle = window.adsbygoogle || []).push({});
    </script2>
halaei commented 5 years ago

I don't think the memory leak relates to loading scripts multiple times. My guess is adsens isn't compatible with single page apps and we should use Google ad manager instead.

mazipan commented 4 years ago

Closed for now