Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backbone.Validation.bind memory leak #118

Open
bigluck opened this issue Apr 9, 2013 · 3 comments
Open

Backbone.Validation.bind memory leak #118

bigluck opened this issue Apr 9, 2013 · 3 comments

Comments

@bigluck
Copy link

bigluck commented Apr 9, 2013

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

Global Blue Admin-1

@kayhadrin
Copy link

Apologies for being a bit out of topic.
What's the program you're using to analyse this issue?

@bigluck
Copy link
Author

bigluck commented May 3, 2013

I've used the Google Chrome Profiles taking Heap Snapshots

@boycce
Copy link

boycce commented Jul 4, 2014

@bigluck Hey, did you manage to find a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants