RuntimeException
RuntimeException

Reputation: 1135

Backbone single page application - Memory leak

I have got 6-7 pages application which is using backbone views, jQuery and high charts. I have noticed that it is leaking memory. It become unresponsive if I leave it running for 10 minutes. Someone suggested me to destroy views when not in use and I did this according to this answer.

Destroy or remove a view in Backbone.js

Which improved app but still I have got memory issues. I'll appreciate if someone could guide me in correct direction. Is there anything else I can do to improve memory leaks?

Upvotes: 0

Views: 920

Answers (2)

Andrey Kuzmin
Andrey Kuzmin

Reputation: 4479

Most of memory leaks happen because of ghost events.

I suggest using listenTo when binding to events inside views. Calling view.remove() will automatically unbind them.

Upvotes: 2

Vitalii Petrychuk
Vitalii Petrychuk

Reputation: 14225

First of all you need to detect the root cause and only then fix it.

Tools for debugging memory leaks in JavaScript

Also I suggest to watch this screencast http://www.youtube.com/watch?v=L3ugr9BJqIs

Upvotes: 1

Related Questions