InnerHTML leads to an increasing number of DOM Node.

Picture

related codes
<!DOCTYPE html>
<html>
<head>
    <title>test</title>
</head>
<body>
<div id="test"></div>
<script>
    var oTest = document.getElementById("test");
    var i = 0;
    setInterval(function() {
        oTest.innerHTML = iPP;
    }, 10);
</script>
</body>
</html>
description

encountered a problem with the page crash. The window.performance that printed the Chrome before the page creah found that all the used js stack memory (sedJSHeapSize) did not exceed the current js stack memory size (totalJSHeapSize). Now I wonder if the number of page DOM exceeds the threshold, which causes the page crash, to find that the reason for the rising DOM Nodes in the page is that although the use of innerHTML, is finally garbage collected, will the number of DOM exceed the threshold due to an unsuccessful garbage collection.

question

question 1: the increase in: DOM Nodes is mainly due to the fact that DOM has not been recycled, mainly reference , but why does innerHTML lead to the increase of DOM nodes?
question 2: how to print DOM Nodes (, including unrecycled ones, like printing window.performance? document.getElementsByTagName ("*") .length can only print what is available on the page. I can print this number before the page crash to check whether the page crash is caused by the number of DOM exceeding the threshold

.

Hello, subject.

problem 1: there is no memory leak when analyzing the code given by the subject with chrome performance. In the picture given by the subject, I see that the memory still shows an upward trend even after the memory is recycled. Please feedback the results after the observation time is longer. Also ask the subject to pay attention to: is the problem caused by the browser plug-in (rather than the front-end code)?

another: the subject asks why innerHTML leads to the increase of DOM nodes. This is the DOM NODE type:, the code keeps creating, DOM NODE, will naturally rise (but because there are no additional references, it will be logically recalled by gc, there is no memory leak)

question 2: refer to Google's documentation


has the landlord finally determined the reason? I have been slowly increasing

, too.
Menu