Finding JavaScript memory leaks with Chrome

后端 未结 8 1544
滥情空心
滥情空心 2020-11-28 00:07

I\'ve created a very simple test case that creates a Backbone view, attaches a handler to an event, and instantiates a user-defined class. I believe that by clicking the \"R

8条回答
  •  借酒劲吻你
    2020-11-28 00:34

    Here's a tip on memory profiling of a jsfiddle: Use the following URL to isolate your jsfiddle result, it removes all of the jsfiddle framework and loads only your result.

    http://jsfiddle.net/4QhR2/show/

    I was never able to figure out how to use the Timeline and Profiler to track down memory leaks, until I read the following documentation. After reading the section entitled 'Object allocation tracker' I was able to use the 'Record Heap Allocations' tool, and track some some Detached DOM nodes.

    I fixed the problem by switching from jQuery event binding, to using Backbone event delegation. It's my understanding that newer versions of Backbone will automatically unbind the events for you if you call View.remove(). Execute some of the demos yourself, they are set up with memory leaks for you to identify. Feel free to ask questions here if you still don't get it after studying this documentation.

    https://developers.google.com/chrome-developer-tools/docs/javascript-memory-profiling

提交回复
热议问题