jQWidgets Forums

jQuery UI Widgets Forums Plugins AngularJS jqxGrid will cause memory leaking when work with angular

This topic contains 3 replies, has 2 voices, and was last updated by  zmlcoder 8 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • zmlcoder
    Participant

    Hello,

    I am working the jqWidgets with the angular, then I found seems there would be some memory leaking when using the jqxGrid.

    I created one simple test case in http://plnkr.co/edit/Khgo7Lx4XbTlRyM977kF

    The demo contain two button to navigate ‘step1’ between ‘step2’.

    The reproducing steps:
    1. Go into step1, then open the Chrome dev tool and switch to Profiles, take one Snapshot for the js heap(Snapshot1).
    step1
    2. Clikc the ‘step2222’ button to route into step2 page.
    step2
    3. Click the ‘step1111’ button to route back to step1 page, then take one Snapshot for the js heap(Snapshot2).
    step3
    4. Select ‘Snapshot2’ then compare with ‘Snapshot1’ via switch the view to ‘Comparison’.
    step4
    5. Input ‘scope’ into ‘Class filter”.
    step5
    6. Input ‘jqx’ into ‘Class filter’

    Expect result:
    5. Just remain ‘ChildScope’ of ‘Step1Controller’ and the ‘ChildScope’ of ‘Step2Controller’ should be destroy.
    6. The objects from jqWidget should be removed.

    Actual result:
    5. The ‘ChildScope’ of ‘Step2Controller’ still remain stay in memory.
    result5
    6. The ‘i.jqx.dataAdapter’ still remain in memory.
    result6
    My analyze:
    5. Select the ‘ChildScope’ of ‘Step2Controller’, in Retainers view, we can find there is one reference ‘jqx._jqxGrid.prototype.definedInstance’ to the scope. Then I check the code, I found in ‘jqxAngular.js’, the ‘extendInstance’ method will extend the jqxGrid prototype with the ‘definedInstance’ method, which would hold the scope instance in the jqxGrid prototype. And I can not find any remove code in the ‘destroy’ method. I think maybe it is the cause.
    analyze5

    6. The ‘i.jqx.dataAdapter’ seems also missing some clean action.

    If have any doubt, pls feel free to contact me.
    Thanks in advance.


    zmlcoder
    Participant

    hmmmmmm, seems screenshots are failed to display, maybe can take a look from https://github.com/zmlcoder/jqx_snapshots


    Peter Stoev
    Keymaster

    Hi zmlcoder,

    The Grid releases its memory when “destroy” is called.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    zmlcoder
    Participant

    Hello Peter,

    Yes, I know it, and the destroy method is also called during the routing. However, from the js heap snapshot, we can find ‘jqx._jqxGrid.prototype.definedInstance’ still reference to the scope, which will cause the scope can not be destroy. Furthermore, the ‘definedInstance’ is extended on prototype, this is why I think we should release this reference manually.

    I think the test case can reproduce this issue, maybe try first 🙂

    Thanks in advance.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.