首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Chrome75错误?:在编写文本时,不会对HTMLInputElement元素进行垃圾回收

Chrome75错误?:在编写文本时,不会对HTMLInputElement元素进行垃圾回收
EN

Stack Overflow用户
提问于 2019-07-25 23:03:22
回答 1查看 125关注 0票数 0

我正在通过编程从DOM中删除HTMLInputElement。然后我运行堆转储,这些HTMLInputElements不在堆转储中。

但是,当我输入HTMLInputElement时,HTMLInputElement不会被垃圾回收,我可以在堆转储(在构造函数中)中看到它。

如果有附加到这些元素的处理程序,相关对象也不会从内存中丢弃。

在Chrome 75中观察到。

似乎IE11没有遇到这个问题。

代码语言:javascript
复制
<html>
<body>

<button id="button">Add</button>
<div id="container"></div>

<script>

    var button = document.getElementById("button");
    var cont = document.getElementById("container");

    button.addEventListener("click", function() {
        if (cont.childNodes.length > 0) {
            cont.removeChild(cont.childNodes[0]);
        }
        var input = document.createElement("input");
        input.type = "text";
        cont.appendChild(input)
    })

</script>

</body>
</html>

我希望这些元素会被丢弃。

EN

回答 1

Stack Overflow用户

发布于 2019-07-26 05:06:06

我也一样- 75.0.3770.142 (64位)版本。

然而,随机选择的32位铬的旧版本- 69.0.3450.0 -似乎没有这个问题。

构建在这里:https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win/564085/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57205068

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档