Skip to content
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

gpt-ads-module - Potential Memory leak #38

Open
ronen-e opened this issue Oct 3, 2020 · 0 comments
Open

gpt-ads-module - Potential Memory leak #38

ronen-e opened this issue Oct 3, 2020 · 0 comments

Comments

@ronen-e
Copy link

ronen-e commented Oct 3, 2020

Problem

The plugin injects gptAds to the application and the GptAd component adds to the $gptAds.slots array inside the mounted hook:

this.$gptAds.slots.push(adSlot);

The beforeDestroy() hook uses googletag.destroySlots method as it should.

const destroyed = googletag.destroySlots([this.adSlot]);

However there is no cleanup of this.$gptAds.slots when the component is removed, thus keeping the adSlot in memory, event after the component is destroyed.

Is this intentional ?

Possible solution

I think the adSlot should be also removed from this.$gptAds.slots.
For example:

const destroyed = googletag.destroySlots([this.adSlot]);
this.$gptAds.slots = this.$gptAds.slots.filter(adSlot => adSlot != this.adSlot);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant