Skip to content

gpt-ads-module - Potential Memory leak #38

@ronen-e

Description

@ronen-e

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions