Created
May 13, 2015 19:32
-
-
Save davydog187/2a1499fec7c517252e25 to your computer and use it in GitHub Desktop.
GPT Related Memory Leak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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