Tool to track down JavaScript memory leak

前端 未结 3 670
抹茶落季
抹茶落季 2020-11-28 05:32

I have a web application which has a memory leak somewhere and I am unable to detect it. I already tried the Chrome developer tools which normally works great, but I am unab

3条回答
  •  佛祖请我去吃肉
    2020-11-28 06:08

    jQuery ajax requests were the biggest culprit in my app. Locate all your ajax jQuery functions: .ajax(), .get(), .post() and content setters: .html(), .text().

    Go to the network tab in dev tools, refresh the current page 10 to 20 times. If you see things stacking up too frequently, or calls not being completed, you have a memory leak.

    Here is a recent memory leak I was able to solve with jQuery.load()...

    if(!jQuery.terms_html) $('#tc_container').load(STATIC_DOMAIN + '/terms.html', function() { jQuery.terms_html = $('#tc_container').html() }) else $('#tc_container').html(jQuery.terms_html)

    Also, the latest version of jQuery at time of writing this is 3.3.1. Having the latest version installed is the best way to get started, if possible. https://github.com/jquery/jquery/releases

提交回复
热议问题