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
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
106 | HTTP 접근 제어 (CORS) | 황제낙엽 | 2017.05.29 | 472 |
105 | innerHTML | 황제낙엽 | 2008.11.03 | 472 |
104 | Understanding delete | 황제낙엽 | 2011.11.28 | 470 |
103 | javascript replaceall의 방법에 따른 처리 속도 비교 | 황제낙엽 | 2009.02.11 | 469 |
102 | Javascript delete | 황제낙엽 | 2012.06.11 | 468 |
101 |
자바스크립트 타입 비교 테이블 + 테이블 작성 스크립트
[1] ![]() | 황제낙엽 | 2017.06.23 | 467 |
100 | 다양한 WYSIWYG 에디터 | 황제낙엽 | 2011.11.13 | 466 |
99 | Dynatrace For Ajax Performance | 황제낙엽 | 2010.08.18 | 462 |
98 | 라이노 (Rhino) 관련 링크 모음 | 황제낙엽 | 2008.07.21 | 461 |
97 | Top 10 JavaScript Performance Tips+Android & iPhone Engine Testing | 황제낙엽 | 2011.11.04 | 459 |
96 | 숫자값으로의 변환 형태 | 황제낙엽 | 2009.09.02 | 459 |
95 | 자바스크립트 쿠키 | 황제낙엽 | 2009.06.11 | 459 |
94 | 테이블 엘리먼트 생성 스크립트 | 황제낙엽 | 2009.04.07 | 458 |
93 | User Agent 관련 Reference URL | 황제낙엽 | 2011.02.22 | 457 |
92 |
YUI Compressor in Java
![]() | 황제낙엽 | 2011.07.04 | 456 |
91 | 소숫점을 포함한 반올림 | 황제낙엽 | 2008.12.11 | 454 |
90 | 3시간 걸려서 만든 입력폼 자릿수체크 스크립트 | 황제낙엽 | 2006.04.22 | 454 |
89 | 자바스크립트 예약어 | 황제낙엽 | 2010.11.03 | 452 |
88 | XMLHttpRequest.setRequestHeader | 황제낙엽 | 2013.09.30 | 451 |
87 | 상속과 Super 로의 접근 | 황제낙엽 | 2012.09.18 | 451 |