ext-js grid memory leaks explained (and solved)

January 5th, 2009
  • Hello Ext-Users,

    This is my first post here, so let me introduce myself first.

    My name is Yann Herve and I work as a software developper for a telco company.
    I have developped an application to configure and monitor our network element using dojo and I am now thinking of porting the code to ext-js.

    From my one year experience developping ajax, the pb of memory leak is very important and should be considered early in any project. I thought that taking some time to investigate extjs memory leaks would be a good way to make an evaluation of the library and learn how to use it.

    So I have made a report of my investigations. You can find it at the following url.

    http://membres.lycos.fr/yhv/grid_leak_report.html

    Hope you'll find it useful and that the proposal I make to automatically release event handlers will be implemented in the extjs in the future.

    Yann


  • very nice write up indeed..... never thought of all that :)


  • Hi herve,

    I have a couple of things to note:

    1. There was actually a major leak found in 1.1 Beta 1 thru RC1 with ext-base that has been corrected in SVN and will be in the next release due out shortly.

    2. To automatically clean up event listeners, you can turn on listener collection in the garbage collector thread:

    Ext.enableListenerCollection = true;

    The good thing is it then happens behind the scenes for all Ext.Elements - not just ones used with components.

    3. Some of the issues in your paper (e.g. the Grid stylesheets issue) were corrected in RC1.

    Thanks for sharing and providing the nice write up.


  • 2. To automatically clean up event listeners, you can turn on listener collection in the garbage collector thread:

    Ext.enableListenerCollection = true;

    The good thing is it then happens behind the scenes for all Ext.Elements - not just ones used with components.



    Hi Jack,

    Yes, I tried to turn this option on, but it didn't solve the problem. The reason is that the garbage collector of the 'Element' class collects only the elements reachable from the cache (the ones obtained using Ext.get). The implementation of the Grid does not use this mechanism (direct instanciation of Element). So if you want the automatic listener removal to actually unregister all the listeners, you have to prevent people from adding a listener using the 'on' mechanism directly on a DOM element. (I also have a concern with the scability of the GC mechanism, especially on slow js implementation such as IE6)

    Yann







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about ext-js grid memory leaks explained (and solved) , Please add it free.