Memory leak involving jQuery Ajax requests

后端 未结 3 2074
攒了一身酷
攒了一身酷 2020-12-18 04:21

I have a webpage that\'s leaking memory in both IE8 and Firefox; the memory usage displayed in the Windows Process Explorer just keeps growing over time.

The followi

3条回答
  •  情歌与酒
    2020-12-18 04:38

    I'm not sure about the leak, but your resetTable() function is very inefficient. Try fixing those problems first and see where you end up.

    • Don't append to the DOM in a loop. If you must do DOM manipulation, then append to a document fragment, and then move that fragment to the DOM.
    • But innerHTML is faster than DOM manipulation anyway, so use that if you can.
    • Store jQuery sets into local variables - no need to re-run the selector every time.
    • Also store repeated references in a local variable.
    • When iterating over a collection of any sort, store the length in a local variable, too.

    New code:

     
        Test Page
        
     
    
    
    MPE Bin When Filtered Failed

    References:

    • jQuery Peformance Rules
    • Speed Up Your Javascript

提交回复
热议问题