本文介绍了IE6内存泄漏 - 非常繁琐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我一直在努力确定IE6中的内存泄漏几个WEEKS

吧。我已经完成了我的谷歌搜索等等,并且知道所有关于常见的

泄漏,如循环引用和闭包,但没有发现像

这个。

这个应用程序设计用于在自助服务终端环境中运行,因此它有一个像持久性框架一样的东西,它包含数据以及可见的

框架(实际上是一个iframe)。在1,000页转换后,我们的应用程序已经上涨了近20MB;考虑到售货亭可以运行数天甚至数周这个

绝对不是理想的。肯定会发生很多事情,

但是我设法把泄漏归结为一个非常奇怪的情况。


我有我使用

navigate()函数点击两个相同的测试页面。我绝对相信有问题的标签有

他们的事件处理程序在页面导航之前设置为null。


以下显示泄漏(道歉,我的新闻服务器不允许

HTML标签):


[a onmousedown =" navigate(''testPage2.html'');"]点击我[/ a]


下面没有泄漏(有一点点泄漏,但没有接近

):


[a href =''#''onmousedown =" navigate(''testPage2.html'');"]点击我[/ a]


以下DOES泄漏:


[a onmousedown =" location.href =''#''; navigate(''testPage2 .html'');"]点击我[/ a]


有没有人知道为什么会这样,忽略在页面加载/卸载时执行的大量

代码?为什么点击那个

链接只有在分配了一个href时才会泄漏?那会不会发生什么事?

怪异的事件可能会冒泡吗?或者发射一个额外的事件(或*不*

发射一些其他事件)?为什么当通过JavaScript分配

location.href时,魔法也不会出行?


任何对此有任何想法的人都被邀请制作我的生活很多

更快乐。非常感谢!


- 丹尼尔奥纳

Hi all,

I''ve been trying to pin down a memory leak in IE6 for several WEEKS
now. I''ve done my share of googling etc., and know all about common
leaks like circular references and closures, but have found nothing like
this.
This app is designed to run in a kiosk environment, so it has
things like a persistent frame which holds data as well as the visible
frame (actually an iframe). After 1,000 page transitions our app is up
by almost 20MB; considering kiosks can run for days or even weeks this
is definitely not ideal. There''s definitely a lot of stuff happening,
but I''ve managed to pin the leak down to a very odd case.

I have two identical test pages which I click between using a
navigate() function. I am absolutely sure that the tags in question have
their event handlers set to null before the page is navigated away from.

The following shows the leak (apologies, my news server disallows
HTML tags):

[a onmousedown="navigate(''testPage2.html'');"]CLICK ME[/a]

The following does NOT leak (there''s a small leak but nowhere near
as much):

[a href=''#'' onmousedown="navigate(''testPage2.html'');"]CLICK ME[/a]

The following DOES leak:

[a onmousedown="location.href=''#'';navigate(''testPage2 .html'');"]CLICK ME[/a]

Does anyone have any clue why this might be, ignoring the mass of
code that gets executed on page load/unload? Why would clicking that
link not leak only when there''s an href assigned? Does that do something
weird to the event bubbling, perhaps? Or fire an extra event (or *not*
fire some other event)? And why wouldn''t the magic also trip when
location.href is assigned via JavaScript?

Anyone who has any idea about this is invited to make my life a lot
happier. Thanks very much!

--Daniel Orner

推荐答案




不,我试过了,它没有重新加载页面,在至少在IE6上。如果

确实如此,那么在onmousedown处理程序中会发生同样的事情,

然而它们的行为却不同。

导航()基本上移到下一页。就像我说的那样,那里有很多东西(包括几个帧/ iframe),

但是我想专注于添加href =''#''

属性并删除它之间的区别。

No, I tried it and it doesn''t reload the page, at least on IE6. And if
it did, the same thing would have happened in the onmousedown handler,
and yet they act differently.
The navigate() basically moves to the next page. Like I said, there''s a
lot of stuff going on there (there are several frames/iframes involved),
but I''d like to concentrate on the difference between adding an href=''#''
attribute and removing it.




当然不是。阅读RFC3986。

PointedEars

-

var bugRiddenCrashPronePieceOfJunk =(

navigator.userAgent.indexOf('' MSIE 5'')!= -1

&& navigator.userAgent.indexOf(''Mac'')!= -1

)// Plone, register_function.js:16

Of course not. Read RFC3986.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf(''MSIE 5'') != -1
&& navigator.userAgent.indexOf(''Mac'') != -1
) // Plone, register_function.js:16


这篇关于IE6内存泄漏 - 非常繁琐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 03:31