说明: 本篇内容摘自本站一位仁兄的,在这里加贴是为了做点补充并上传附件方便后来的朋友下载和学习。
javascript内存泄露的问题一直以来都不受到大家的重视,原因是对用户的影响没有太实际的表现,或许近几年内存发展迅速。脚本内存再泄露也不会有太大影响。
当然作为前端开发的同学们,就不能有这样的侥幸心理。出现memory leaks很大程度上是因为程序的不成熟和编码不太规范造成的。不过,这里就不说如何出现问题的,对问题的出现有兴趣可以参考以下地址:
•Understanding and Solving Internet Explorer Leak Patterns
•IE's memory-leak fix greatly exaggerated
•Memory Leakage in Internet Explorer – revisited
这里主要说说,目前几个检查javascript内存泄露的工具使用方法:
首先我们用到的工具有三个 Drip/sIEve ,Javascript Leaks Detector, leak monitor。其中前两个是用于检查ie的,leak monitor 是用来检查firefox的情况的。这里重点说一下ie下的这两个工具,由于firefox的GC机制比ie强壮,只要ie的问题消除了,其他浏览器基本上不会有什么问题。
1.Drip/sIEve
Drip和sIEve的作者应该是同一个人,连open souce上的项目都是在一起的。不过,平时我们主要使用sIEve就可以了,sIEve的功能比Drip强大一些
sIEve 界面很简单,左侧:内嵌了一个浏览器控件,我可以访问任何网址,下方还有个内存检查,这样我们可以方便看出内存的升降情况以及dom使用数量曲线。
右侧面板,我们可以通过 Show in use 看到目前页面使用的dom的情况,Show Leaks 可以看到内存泄露的dom。当然每次显示泄露的情况必须是页面刷新后,看到上一个页面的泄露情况。
同时通过右侧的数据颜色,我们可以看到内存的升降和具体的数量级
•
不过sIEve的工作原理是对所有dom进行了一次hack,然后自己判断那些dom没有被释放掉,但是具体的情况比较难分析出来。而且跟踪有问题的dom需要一定技巧,对于大型的应用程序,跟踪难度大。
不过用来检测小模块的内存使用情况还是一个不错的选择,特别是大项目模块细分后,对每个模块的单独测试还是比较不错的
谢谢怿飞同学提示的下载地址, Drip/sIEve下载地址:
http://home.orange.nl/jsrosman/
2. Javascript Leaks Detector
这是来自微软GPDE团队的一个小工具,下面简称JLD
官网: http://blogs.msdn.com/gpde/pages/javascript-memory-leak-detector.aspx
安装后,我们可以在ie浏览器的 查看->浏览器栏中找到
JLD强大之处在于能够模拟IE6和IE7的GC情况,和真实的回收情况。这样可以做一个比较。
这里通常能只能反应IE6和IE7的理想情况,我们需要选择下面Actual Leaks来反映当前浏览器的真实情况。
浏览器刷新后,我们就可以看到上次页面的结果了,绿色代表没有发现内存泄露,红色代表发现了内存泄露,蓝色是当前加载完成的页面,当然还有黑色,是指正在加载的网页
当我们展开一个有问题的页面时,
我们可以看到一个有问题分支Leaks.这里列出了有问题的节点,同时还能帮我们列出出现问题的脚本在什么地方。
这点非常方便我们定位出泄露的问题所在。不过要使用脚本调试,我们必须要打开ie的脚本调试功能
在ie选项的高级中,我们去掉这两个勾即可
3. Leak Monitor
这是firefox上唯一一个检查内存泄露的工具,不过这里舜子不太推荐使用。因为firefox的内存GC机制比IE强悍,不必作为重点考虑对象。只要 ie的问题能处理好,firefox上基本上也没有什么问题。而且有ie这两个强悍的软件帮忙基本上能解决大部分问题了。
可惜这个工具的体验很糟糕,会让人很有一种抓狂的感觉。如果您还要继续尝试可以到这里下载: https://addons.mozilla.org/zh-CN/firefox/addon/2490
以下是关于JavaScript Memory Leak Detector 的使用与介绍
Introduction
JavaScript Memory Leak Detector (download) is a debugging tool to detect memory leaks and enforce best practices in JavaScript code when working with version of Internet Explorer older than IE8.
As described in detail in this MSDN article the JScript garbage collector in previous versions of Internet Explorer manages the lifetime of JScript objects but not of DOM objects. As a result, the JScript garbage collector cannot break circular references between DOM objects and JScript objects, and memory leaks may occur.
In IE6, these circular references are broken when the Internet Explorer process terminates (and leaks are very frequent).
In IE7, these circular references are broken when users navigate away from the page.
In IE8 the problem is completely mitigated. (Read here for more details).
Programmers who need to support older versions of the Internet Explorer browser should still try to pay attention to programming patterns such as JScript closures, as they could cause memory leaks.
The leak detector works hosting an IE WebBrowser control and intercepting the execution of JavaScript inside IE. It monitors al the DOM elements in the markup of a web document that somehow interact with JavaScript and presents a list of potentially leaked objects to the user, together with information about the scripts loaded in the page and, if possible, a hint to the instruction that may have caused the leak.
Installation notes
IEJSLeaksDetector is a plain, native, Windows application and does not require any particular setup (the executable can be just unzipped and run).
It only runs in 32 bit versions of Windows. 64 bits editions are not supported yet.
There are only two installation steps required to make sure that the tool works correctly:
1. The tool requires that the pdm.dll script installer is installed in the machine. This DLL is normally installed with any version of Microsoft Visual Studio.In case you are unable to install Visual Studio in the target machine, a simpler way to install pdm.dll is by installing the Microsoft Script Debugger, freely downloadable here.
2. The tool also requires Internet Explorer script debugging to be enabled to work correctly. Verify that the check box "Disable script debugging (Other)" is unchecked, in IE ('Tools' menu -> Internet Options -> 'Advanced' tab -> 'Browsing' section) as shown in figure.
How to use the tool
The user can start the memory profiling of a web application navigating to the desired URL. A new tab is opened with a WebBrowser control and a tree view shows all the documents and scripts that compose the current page.
When the user has finished to interact with the page he can click the "Stop" button, which causes the tool to close the control and track possible leaks.
Memory leaks are listed specifying the DOM object's type and a list of "attached" JavaScript objects whose circular reference could be the cause of the leak. The tool also shows the call stack correponding to a memory leak, which represents the state of the script at the moment when the JavaScript object was attached to the DOM object. Finally, a script window highlights the exact point in the JavaScript code where the memory leak originated.
More information can be found in the docs enclosed with the binaries.
Posted: Monday, August 03, 2009 11:28 AM by eurojobs
Filed under: JavaScript, Internet Explorer, Debugging tools
Comments
nora said:
Thank you new version release!
so,is JavaScript Memory Leak Detector (v2) supported protetype.js which isn't supported by previous version ?
thanks.
# September 1, 2009 8:15 AM
eurojobs said:
nora,
Thanks for your interest!
I don't have 'protetype.js' to run a test, but the new version should be considerably more stable than the previous one.
But please, let me know if you find any problem.
# September 1, 2009 9:35 AM
New Comments to this post are disabled
IEJSLeaksDetector2.0.1.1.zip (471.7 KB)
scd10en.rar (606.3 KB)
JSLeaksDetector.msi.zip (216.6 KB)
发表评论
-
基于脚本的动画的计时控制(“requestAnimationFrame”)(转载)
2014-03-04 19:12 946Internet Explorer 10 和使 ... -
IE11开发人员工具:UI响应工具详解
2014-02-27 18:33 889我讨厌debug,相信也没多少开发者会喜欢。但是当代码出 ... -
IE11开发人员工具:内存分析工具详解
2014-02-27 18:32 1378上篇我们跟大家介绍 ... -
E6与location.hash和Ajax历史记录 (转载)
2014-02-26 12:23 519为了在IE6中改变hash来保留历史记录实现ajax的前进 ... -
MIME Types(转载)
2013-12-31 10:20 604MIME Types - Complete List ... -
iframe历史记录问题(转载)
2013-10-17 10:21 1254在做页面统计的时候 ... -
前端类库精选(转)
2013-05-11 00:57 0优秀的前端类库,自己平时遇见了,这里Mark一下。 1、m ... -
10个chrome console实用小技巧(转)
2013-05-09 10:56 10241. 基本输出 让我们先从最常见的console.l ... -
CSS3那些不为人知的高级属性(转)
2013-04-19 13:35 903原文:CSS的未来:一些 ... -
JavaScript 时间、格式、转换及Date对象总结(转)
2013-04-10 14:49 684悲剧的遇到问题,从前台得到时间,“Tue Jan 29 16 ... -
如何制作一个可及性强(accessible)的网页弹框(转载)
2013-04-02 16:18 783英文原文:Making an accessib ... -
JavaScript MVC js也mvc(转载)
2013-03-16 23:59 666JavaScript MVC 中文:http://blog ... -
SUBLIME TEXT 2 设置文件详解
2012-12-27 11:21 1020Sublime Text 2是那种让人会一眼就爱上的编辑 ... -
两个按位非操作与Math.floor操作(译)
2012-12-10 18:17 918位操作符在我们编码过程中是容易被遗忘的,可能更多的源于我们 ... -
img中src为空的影响
2012-11-26 23:32 0这是我们经常能遇到的代码,可以直接用html标签或者Java ... -
IE6下position定位子元素溢出,父元素被撑开的解决思路。(转)
2012-11-13 18:04 1608在一些被常规的页面布局当中,我们常常需要通过positi ... -
chrome developer tool 调试技巧(转)
2012-11-12 13:16 815这篇文章是根据目前 chrome 稳定版(19.0.10 ... -
你清楚jquery是如何清除ajax缓存的吗?(转)
2012-11-11 11:19 1027大家都知道万恶的IE在ajax中往往只读取第一次ajax ... -
是时候使用JavaScript严谨模式(Strict Mode)提升团队开发效率 In JavaScript(转)
2012-11-10 23:33 686随着WebApp突飞猛进的发展,Javascript写的 ... -
Javascript基础
2012-11-10 23:25 0原文:http://bonsaiden.githu ...
相关推荐
javascript 内存泄漏 检测 解决 检测工具 原因分析 资源很多,打包上传 内存泄漏检测工具 分析方法
Javascript内存泄露
JavaScript火灾监测系统.zipJavaScript火灾监测系统.zipJavaScript火灾监测系统.zipJavaScript火灾监测系统.zipJavaScript火灾监测系统.zipJavaScript火灾监测系统.zipJavaScript火灾监测系统.zipJavaScript火灾监测...
理解Javascript理解内存分配原理
sIEve可以有效帮助您监控javascript内存,以协助解决内存泄漏问题。
JavaScript火灾监测系统.7zJavaScript火灾监测系统.7zJavaScript火灾监测系统.7zJavaScript火灾监测系统.7zJavaScript火灾监测系统.7zJavaScript火灾监测系统.7zJavaScript火灾监测系统.7zJavaScript火灾监测系统.7...
该文档是笔者经余月整理后所得,里面包含了JavaScript内存相关的知识概述。大概有浏览器内存管理、JavaScript内存泄漏及补救措施、闭包的概念,希望对诸君有帮助
NULL 博文链接:https://lym6520.iteye.com/blog/317547
javascript内存泄露问题的解析 javascript内存泄露问题的解析javascript内存泄露问题的解析
注意:需要转换的js文件里面不能有注释,有的话,它转换不了。 在网上下载一些js文件,但是打开后,就像一段话一样,好长,好长,没有任何格式,想看一下就不成。
javascript格式化工具javascript格式化工具javascript格式化工具javascript格式化工具javascript格式化工具javascript格式化工具javascript格式化工具
好用的javascript调试工具,方便进去js编写调试。
js调试工具,javascript调试工具
JavaScript学习工具.rarJavaScript学习工具.rarJavaScript学习工具.rarJavaScript学习工具.rarJavaScript学习工具.rarJavaScript学习工具.rar
自己整理的 JavaScript 内存分析,祝你一臂之力!
IE的JavaScript调试工具,感觉还行
JS Beauty 是一款 Javascript 美化工具,它具有美化,净化,压缩和解压缩 Javascript 代码等功能: 1. 美化:将混乱的 Javascript 代码格式化为优美的带缩进的格式,适合阅读和修改。 2. 净化:去掉 Javascript ...
基于JavaScript开发的火灾监测系统源码(课设).zip基于JavaScript开发的火灾监测系统源码(课设).zip基于JavaScript开发的火灾监测系统源码(课设).zip基于JavaScript开发的火灾监测系统源码(课设).zip基于JavaScript...