Memory Leak When Pulling JSON from WEB

后端 未结 3 816
遇见更好的自我
遇见更好的自我 2020-12-20 02:57

I\'ve spent days on this and hit it from every angle I can think of. I\'m working on a simple windows 7 gadget. This script will pull JSON data from a remote web server an

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-20 03:32

    Edit 2:

    If it's actually taskmanager showing the leak here, then I think the next step is to investigate IE, as I believe that IE is then engine used to host Windows Widgets.

    If you can recreate your script in a little html file you can run this tool and have a look if it's IE that's doing it:

    http://blogs.msdn.com/b/gpde/archive/2009/08/03/javascript-memory-leak-detector-v2.aspx

    Also, are you running IE8 or 9 ?


    Edit:

    Based on the JSON string in the Op; basically the problem is misleading here. the bit of javascript posted is working perfectly fine.

    The Server producing the JSON is the one that's showing a difference in memory usage, I would investigate the website/endpoint that's creating that JSON and seeing what the issue is.


    Just had a thought,

    $.getJSON is just a shorthand function for jQuery's $.ajax call.

    I wonder if it makes a different if you change your code to use $.ajax but specifically add the cache mechanism to it:

    $.ajax({
      url: URL + "&callback=?",
      dataType: 'json',
      cache: false,
      success: populateView
    });
    

    That might stop it trying to store it in memory perhaps, and depending on your browser, it might be showing more memory because you just haven't had your garbage collected, so to speak.

提交回复
热议问题