您使用哪些工具和技术来修复浏览器内存泄漏?

时间:2022-09-02 09:06:23

I am trying to fix memory leaks in IE 7. Using Drip for investigations but it is not helping much when most dynamically generated DOM elements do not have unique ids.

我正在尝试修复IE 7中的内存泄漏。使用Drip进行调查,但是当大多数动态生成的DOM元素没有唯一ID时,它没有多大帮助。

Tips?

3 个解决方案

#1


6  

You should try the Javascript Memory Leak detector developed internally at Microsoft.

您应该尝试在Microsoft内部开发的Javascript内存泄漏检测器。

#2


3  

Well, Your best bet is to understand what causes them, so you can look critically at your code, identify patterns that may cause a leak, and then avoid or refactor around them.

好吧,最好的办法是了解导致它们的原因,这样您就可以批判性地查看代码,识别可能导致泄漏的模式,然后避免或重构它们。

Here's a couple of links to get you started, both very informative:

这里有几个链接可以帮助您入门,两者都非常有用:

#3


1  

Just remember that memory leaks are really about you not cleaning up after yourself. All you need is a little organization.

请记住,内存泄漏真的是关于你自己不清理。你需要的只是一个小组织。

In the past, I have created my own proxy object for attaching events to DOM elements. It uses my javascript library's api to actually set and remove events. The proxy itself just keeps track of all of the references so that I can call a method on it to have it clean up all of my potential memory leaks.

在过去,我创建了自己的代理对象,用于将事件附加到DOM元素。它使用我的javascript库的api来实际设置和删除事件。代理本身只是跟踪所有引用,以便我可以在其上调用一个方法来清除所有潜在的内存泄漏。

For my purposes, I was able to just call a single deconstructor on the page that would clean up the leaks for the entire page when the user was leaving the page.

出于我的目的,我能够在页面上调用单个解构器,以便在用户离开页面时清除整个页面的泄漏。

You may have to be more granular but the technique is the same.

您可能必须更精细,但技术是相同的。

#1


6  

You should try the Javascript Memory Leak detector developed internally at Microsoft.

您应该尝试在Microsoft内部开发的Javascript内存泄漏检测器。

#2


3  

Well, Your best bet is to understand what causes them, so you can look critically at your code, identify patterns that may cause a leak, and then avoid or refactor around them.

好吧,最好的办法是了解导致它们的原因,这样您就可以批判性地查看代码,识别可能导致泄漏的模式,然后避免或重构它们。

Here's a couple of links to get you started, both very informative:

这里有几个链接可以帮助您入门,两者都非常有用:

#3


1  

Just remember that memory leaks are really about you not cleaning up after yourself. All you need is a little organization.

请记住,内存泄漏真的是关于你自己不清理。你需要的只是一个小组织。

In the past, I have created my own proxy object for attaching events to DOM elements. It uses my javascript library's api to actually set and remove events. The proxy itself just keeps track of all of the references so that I can call a method on it to have it clean up all of my potential memory leaks.

在过去,我创建了自己的代理对象,用于将事件附加到DOM元素。它使用我的javascript库的api来实际设置和删除事件。代理本身只是跟踪所有引用,以便我可以在其上调用一个方法来清除所有潜在的内存泄漏。

For my purposes, I was able to just call a single deconstructor on the page that would clean up the leaks for the entire page when the user was leaving the page.

出于我的目的,我能够在页面上调用单个解构器,以便在用户离开页面时清除整个页面的泄漏。

You may have to be more granular but the technique is the same.

您可能必须更精细,但技术是相同的。