Code Monkey home page Code Monkey logo

Comments (7)

grabbou avatar grabbou commented on July 28, 2024

This will trigger when you change the view as well causing massive lag between views, unfortunately. Encountered that few days ago while creating my isotope wrapper.

from angular-slick.

paynecodes avatar paynecodes commented on July 28, 2024

@grabbou What do you mean by "this".

@deedarb's suggestion, or the plugin as is.

from angular-slick.

grabbou avatar grabbou commented on July 28, 2024

This = scope.$on('destroy') event. The thing is - when you have 100 items in your slider and you navigate to another route using ui-router causing the whole view to be rendered once again using different templates, you will notice massive lag as destroy will be called 100 times. AFAIK once item is removed from DOM, event listeners should be GC anyway. Haven't noticed any lags in my code because of that. $destroy can be called on main angular-slick directive to do the clean up but not on single elements tough.

from angular-slick.

paynecodes avatar paynecodes commented on July 28, 2024

@grabbou Event listeners on DOM elements (in the dom or not) are not automatically GC'ed. I don't think anyone is suggesting that $destroy is called 100 time for 100 slides. That would only happen when you have 100 instances of <slick> directive.

See this

from angular-slick.

grabbou avatar grabbou commented on July 28, 2024

Ah, sorry. I thought that we have 'sub directive' inside directive that displays every single slide. In that case, $destroy event is completely fine. In 99% cases though memory consumed by event handlers triggered on DOM elements is trivial compared to the overall memory used by a webpage. But again, having checked the code once again, it's an easy way to improve code quality.

from angular-slick.

tilwinjoy avatar tilwinjoy commented on July 28, 2024

I have tested for memory leak, and this does cause memoery leak. I have fixed this for now by by wrapping this in my own directive. Came here searching for existing issues before I make a PR, then noticed the source is coffeescript as mentioned in OP.

Please add a destroy handler.

from angular-slick.

tilwinjoy avatar tilwinjoy commented on July 28, 2024

@grabbou

memory consumed by event handlers triggered on DOM elements is trivial

Yes. But in angular this causes the detached elements to stay in memory, some of these elements holds references to scope(s), scope holds references to parent scopes, child scopes etc and they holds references to lots of data. Eventually those tiny handlers cause huge memory leak. This is a serious issue than just an improvement to code quality...

from angular-slick.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.