有人可以验证这是 IE8 内存泄漏吗?
泄漏很容易造成。 将下面的 HTML 放在名为“TestImage0.jpg”、“TestImage1.jpg”、...“TestImage9.jpg”的大图像列表旁边。 每次点击页面时,该页面都会泄漏内存(我使用 sIEve 进行测试)。 如果去掉resize css,页面就不会泄漏。 谁能确认这是 IE8 的问题,还是我的实验有缺陷?
测试代码
<html>
<head>
<title>Memory Leak Testing</title>
<script type="text/javascript">
var count = 0;
window.onload =
function() {
AppendImage();
window.document.body.onclick = ReplaceImage;
}
var ReplaceImage = function() {
window.document.body.removeChild(document.getElementById('MemTestObject' + count));
count++;
if (count > 9) {
alert('No more images to load.');
} else {
AppendImage();
}
}
var AppendImage = function() {
var imageObject = document.createElement('img');
imageObject.id = 'MemTestObject' + count;
imageObject.className = 'MemTestObject';
imageObject.src = 'TestImage' + count + '.jpg';
window.document.body.appendChild(imageObject);
}
</script>
<style type="text/css">
.MemTestObject {
width: 140px;
height: 178px;
}
</style>
</head>
<body>
<h1>Memory Leak Testing</h1>
</body>
</html>
The leak is pretty easy to create. Place the HTML below alongside a list of large images named "TestImage0.jpg", "TestImage1.jpg",..."TestImage9.jpg". The page will leak memory (I used sIEve for testing) on every click of the page. If the resize css is removed, the page will not leak. Can anyone confirm that this is an IE8 problem, or that my experiment is flawed?
Test Code
<html>
<head>
<title>Memory Leak Testing</title>
<script type="text/javascript">
var count = 0;
window.onload =
function() {
AppendImage();
window.document.body.onclick = ReplaceImage;
}
var ReplaceImage = function() {
window.document.body.removeChild(document.getElementById('MemTestObject' + count));
count++;
if (count > 9) {
alert('No more images to load.');
} else {
AppendImage();
}
}
var AppendImage = function() {
var imageObject = document.createElement('img');
imageObject.id = 'MemTestObject' + count;
imageObject.className = 'MemTestObject';
imageObject.src = 'TestImage' + count + '.jpg';
window.document.body.appendChild(imageObject);
}
</script>
<style type="text/css">
.MemTestObject {
width: 140px;
height: 178px;
}
</style>
</head>
<body>
<h1>Memory Leak Testing</h1>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是“有人可以验证这是 IE8 内存泄漏吗?” 答案只能是,是的,有人可以验证这一点。
如果您确实认为这是 IE 中的有效内存泄漏,请首先确保它只是 IE。 然后继续制定具体细节。 一旦您能够准确描述如何重现此泄漏,您可以考虑向 MS 报告,但他们可能不会很快修复它。 但无论如何都要传播这个消息,这样其他人就可以避免陷入陷阱
The question is "Can someone verify that this is an IE8 memory leak?" To which the answer can only be, yes some one could verify this.
If you really think it is a valid memory leak in IE, first make sure that it is just IE. Then carry on working out specifics. Once you can describe exactly how to recreate this leak, you can consider reporting to MS, but they probably will not bother fixing it any time soon. But by all means spread the news so that others can avoid the trap