简体   繁体   English

Ext.js是否存在内存问题

[英]Are There Memory Issues with Ext.js

The UI for an application I work on was recently redone with Ext.js and I have noticed the memory usage of IE seems very large when viewing it. 我工作的应用程序的UI最近使用Ext.js重做,我注意到IE的内存使用量在查看时看起来非常大。 Are there known memory issues with Ext.js when using IE? 使用IE时,Ext.js是否存在已知的内存问题?

The first thing that jumps out at me in your question is that you are seeing this in IE. 在你的问题中,第一件事就是你在IE中看到了这一点。 My team recently went through the same issue (Extjs on IE). 我的团队最近经历了同样的问题(IE上的Extjs)。 It turns out Ext is not the culprit but rather IE is likely the cause. 事实证明,Ext不是罪魁祸首,而是IE可能是原因。

A quick Google for 'IE closure memory leak' will find you plenty of explanations, but the basic gist is as follows: 一个快速谷歌'IE封闭内存泄漏'会找到很多解释,但基本要点如下:

IE uses two separate engines to manage the DOM and JavaScript. IE使用两个独立的引擎来管理DOM和JavaScript。 When JavaScript makes a call to create a DOM element, the Javascript engine reaches across to the other to create it. 当JavaScript调用创建DOM元素时,Javascript引擎会跨越另一个来创建它。 If you attach JavaScript to an event on a DOM element, a link is created back from the DOM side to JavaScript side. 如果将JavaScript附加到DOM元素上的事件,则会从DOM端创建一个链接到JavaScript端。

The problem lies in the fact that each engine has its own garbage collection and can't see across to the other engine. 问题在于每个引擎都有自己的垃圾收集,无法看到其他引擎。 So circular references are REALLY easy to come across that can eat of large quantities of memory very quickly. 因此,很容易遇到循环引用,很快就会占用大量内存。

I think that it's quite easy to create memory leaks when programming with ExtJS for non-experienced programmers. 我认为使用ExtJS为没有经验的程序员编程时,很容易造成内存泄漏。 This is not ExtJS problem on itself. 这本身并不是ExtJS问题。 It's ExtJS programming paradigm which lets programmers to easily make such mistakes. 这是ExtJS编程范例,它让程序员可以轻松犯这样的错误。

From my experience I've created memory leak when tried to make a straighforward AJAX chat using ExtJS. 根据我的经验,当尝试使用ExtJS进行直接的AJAX聊天时,我创建了内存泄漏。 When some objects are constantly created within AJAX callbacks (such as datastores, grid manipulations), then these objects are not released and destroyed. 当在AJAX回调(例如数据存储,网格操作)中不断创建某些对象时,不会释放和销毁这些对象。 There must be special and very clever techniques used to avoid memory leaks with ExtJS, and it's not only related to AJAX or callbacks. 必须有一些特殊的,非常聪明的技术来避免ExtJS的内存泄漏,它不仅与AJAX或回调相关。

All in all, ExtJS is great library, but it must be used carefully. 总而言之,ExtJS是一个很棒的库,但必须小心使用。

Check out this thread in their forums which covers a lot of leaks in Ext 2.2 caused by orphaned elements. 在他们的论坛中查看这个帖子,其中涵盖了由孤立元素引起的Ext 2.2中的大量泄漏。 It seems that Ext 2.2.1 fixed most of them. 似乎Ext 2.2.1修复了大部分内容。

The issue is still Open, btw. 这个问题仍然是开放的,顺便说一句。 ;) ;)

As far as I'm concerned, I haven't heard of notable memory leaks in ExtJS. 就我而言,我没有听说ExtJS中存​​在明显的内存泄漏。 Though I'm sure there have been some, they usually get fixed pretty fast, and the community is so big that most bugs are known. 虽然我确信已经存在一些,但它们通常会很快得到修复,并且社区非常大,以至于大多数错误都是已知的。

Make sure your design is based on individual components that you can add and remove when they are no longer needed since most of the time, an ExtJS webpage will only be loaded once and the mem gets filled with the additional components you give it. 确保您的设计基于可以在不再需要时添加和删除的各个组件,因为大多数情况下,ExtJS网页只会加载一次,并且mem会填充您提供的其他组件。 You can free up some mem using Ext.destroy(this.el) once you have finished using a component. 完成组件使用后,可以使用Ext.destroy(this.el)释放一些内存。

Also, make sure you use Firebug to track down any component or object that should have been removed. 此外,请确保使用Firebug来跟踪应该删除的任何组件或对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM