sitelink1 | |
---|---|
sitelink2 | |
sitelink3 | |
sitelink4 | |
extra_vars4 | |
extra_vars5 | |
extra_vars6 |
<html>
<head>
<script language="JScript">
function LeakMemory()
{
var hostElement = document.getElementById("hostElement");
// Do it a lot, look at Task Manager for memory response
for(i = 0; i < 5000; i++)
{
var parentDiv =
document.createElement("<div onClick='foo()'>");
var childDiv =
document.createElement("<div onClick='foo()'>");
// This will leak a temporary object
parentDiv.appendChild(childDiv);
hostElement.appendChild(parentDiv);
hostElement.removeChild(parentDiv);
parentDiv.removeChild(childDiv);
parentDiv = null;
childDiv = null;
}
hostElement = null;
}
function CleanMemory()
{
var hostElement = document.getElementById("hostElement");
// Do it a lot, look at Task Manager for memory response
for(i = 0; i < 5000; i++)
{
var parentDiv =
document.createElement("<div onClick='foo()'>");
var childDiv =
document.createElement("<div onClick='foo()'>");
// Changing the order is important, this won't leak
hostElement.appendChild(parentDiv);
parentDiv.appendChild(childDiv);
hostElement.removeChild(parentDiv);
parentDiv.removeChild(childDiv);
parentDiv = null;
childDiv = null;
}
hostElement = null;
}
</script>
</head>
<body>
<button onclick="LeakMemory()">Memory Leaking Insert</button>
<button onclick="CleanMemory()">Clean Insert</button>
<div id="hostElement"></div>
</body>
</html>
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
117 | CORS 관련 레퍼런스 URL | 황제낙엽 | 2020.07.10 | 53 |
116 | Navigator 객체란? | 황제낙엽 | 2011.02.22 | 53 |
115 | Function.apply() 와 Function.call() | 황제낙엽 | 2011.10.07 | 51 |
114 | JavaScript 재입문 | 황제낙엽 | 2012.05.29 | 50 |
113 | insertAdjacentHTML Method | 황제낙엽 | 2005.12.19 | 50 |
112 | ECMA 스크립트의 JSON | 황제낙엽 | 2019.10.16 | 48 |
111 | String 에 trim() 함수 적용하기 | 황제낙엽 | 2011.08.28 | 48 |
110 | 3시간 걸려서 만든 입력폼 자릿수체크 스크립트 | 황제낙엽 | 2006.04.22 | 48 |
109 | 멤버 연산자 | 황제낙엽 | 2014.12.30 | 47 |
108 | 연산자 (===, ==, >=, <=) | 황제낙엽 | 2012.05.30 | 47 |
107 | [key:value] 형태로 object를 저장할 수 있는 Static영역의 해쉬맵 클래스 (Map) | 황제낙엽 | 2008.11.04 | 46 |
106 | Dynatrace For Ajax Performance | 황제낙엽 | 2010.08.18 | 45 |
105 | CORS(Cross-Origin Resource Sharing) - 3 | 황제낙엽 | 2017.03.07 | 45 |
104 | 폼으로 XML 데이터 전송 (JSP+Javascript) | 황제낙엽 | 2005.12.04 | 43 |
103 | delete 연산자에 대한 고찰 | 황제낙엽 | 2012.06.11 | 42 |
102 | object clone | 황제낙엽 | 2011.07.08 | 41 |
101 | User Agent 관련 Reference URL | 황제낙엽 | 2011.02.22 | 41 |
» | 잘못된 종속관계 해지에 따른 메모리 누수 예제 | 황제낙엽 | 2009.04.03 | 41 |
99 | [펌] 아사페릴의 사생활 - prototype과 __proto__ 와 constructor | 황제낙엽 | 2009.04.02 | 41 |
98 | withCredentials 관련 | 황제낙엽 | 2020.07.29 | 39 |