Skip to content

Instantly share code, notes, and snippets.

@davydog187
Created May 13, 2015 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davydog187/2a1499fec7c517252e25 to your computer and use it in GitHub Desktop.
Save davydog187/2a1499fec7c517252e25 to your computer and use it in GitHub Desktop.
GPT Related Memory Leak
<html>
<head>
<title>GPT Test Page</title>
</head>
<body>
<div id="01dff7272bfc464224240bc6f1f8d25b"></div>
<button id="refresh">Clear and Refresh</button>
<span>Times refreshed: </span><span id="times">0</span>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement("script");
gads.async = true;
gads.type = "text/javascript";
var useSSL = "https:" == document.location.protocol;
gads.src = (useSSL ? "https:" : "http:") + "//www.googletagservices.com/tag/js/gpt.js";
var node = document.getElementsByTagName("script")[0];
node.parentNode.insertBefore(gads, node);
})();
googletag.cmd.push(function() {
googletag.defineSlot("/5262/business/general", [300, 250], "01dff7272bfc464224240bc6f1f8d25b")
.addService(googletag.pubads())
.setTargeting("position", "box1")
.setTargeting("url", "/");
googletag.enableServices();
});
googletag.cmd.push(function() {
googletag.display("01dff7272bfc464224240bc6f1f8d25b");
});
var refreshButton = document.getElementById("refresh");
var timesSpan = document.getElementById("times");
var refreshCounter = 0;
window.setInterval(function() {
googletag.pubads().clear();
googletag.pubads().refresh();
timesSpan.innerHTML = ++refreshCounter;
}, 2000);
refreshButton.addEventListener("click", function() {
googletag.pubads().clear();
googletag.pubads().refresh();
timesSpan.innerHTML = ++refreshCounter;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment