backbone.validation
backbone.validation copied to clipboard
Backbone.Validation.bind memory leak
Hi everybody, I'm having memory leaks using Backbone.Validation.bind and unbind. If I bind a view and then, before destroy it, I unbind them:
class CountryEditView extends Backbone.View
initialize: ->
@parent = @options.parent
@app = @parent.app
@listenTo @model, 'change', @change
@listenTo @model, 'destroy remove', @back
Backbone.Validation.bind @,
valid: (view, key) ->
if ($ele = view.$("[name=#{key}]")).length
$ele.closest('.control-group').removeClass 'error'
invalid: (view, key, error) ->
if ($ele = view.$("[name=#{key}]")).length
$ele.closest('.control-group').addClass 'error'
remove: ->
Backbone.Validation.unbind @
super
Even if the view has been removed using the remove() method, 3 references persist in memory:
- validate() backbone.validation-0.7.1.js:209
- isValid() backbone.validation-0.7.1.js:189
- preValidate() backbone.validation-0.7.1.js:182
Apologies for being a bit out of topic. What's the program you're using to analyse this issue?
I've used the Google Chrome Profiles taking Heap Snapshots
@bigluck Hey, did you manage to find a solution?