-
Notifications
You must be signed in to change notification settings - Fork 0
/
内存泄露.html
56 lines (51 loc) · 1.6 KB
/
内存泄露.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>内存泄露</title>
</head>
<body>
<div id="nodes"></div>
<script>
// var x = [];
// function createSomeNodes() {
// var div,
// i = 100,
// frag = document.createDocumentFragment();
// for (; i > 0; i--) {
// div = document.createElement("div");
// div.appendChild(document.createTextNode(i + " - " + new Date().toTimeString()));
// frag.appendChild(div);
// }
// document.getElementById("nodes").appendChild(frag);
// }
// function grow() {
// console.log('===')
// x.push(new Array(1000000000).join('x'));
// createSomeNodes();
// setTimeout(grow, 1000);
// }
// grow()
var theThing = null;
var replaceThing = function () {
console.log('xxx')
var originalThing = theThing;
var unused = function () {
if (originalThing)
console.log("hi");
};
theThing = {
longStr: new Array(1000000000).join('*'),
someMethod: function () {
console.log(someMessage);
}
};
// originalThing = null
// return unused
};
setInterval(replaceThing, 1000);
</script>
</body>
</html>