Coder Social home page Coder Social logo

Comments (5)

awerlang avatar awerlang commented on May 23, 2024

Hello!

The stack trace pasted above points to a subscription on the tooltip component (at TooltipDirective.ngOnInit) that isn't being disposed. It either might be disposed at a later time e.g. the routed component is unloaded, or it is in fact a memory leak. In case it's a memory leak, it's likely to be the 3rd-party component's fault. Nothing you can do to fix that except to report to the 3rd-party, or not using the component at all.

The output of the print function is styled as regular errors. Maybe you took that as errors in this tool? They're not, this style allows to print stack traces as well, which makes it easier to spot where the leaking subscriptions are.

At first glance your repro doesn't seem to make any subscriptions, that's why the print function doesn't print anything. You construct a Subject, but no subscription to it is made. If you include a .subscribe() to it there should be an item printed out.

Hope this clears any misunderstanding about how the tool works. Any day I should improve the docs on this.

from observable-profiler.

spiko-md avatar spiko-md commented on May 23, 2024

Hi,

yes, I understood the error printout as errors in the tool :) My first reaction was "I cannot have this many open subscriptions" so I took the errors as incompatibilities with newer angular then the docs are written for - I was unsure if it would even work.

The output could probably be improved by mentioning it is a stack trace to where subscription occurred.

Also, the number of reported subscriptions/printed lines does not seem to match:
Current subscriptions (including indirect/nested): 5
//Lines of output: 3

Can you please look at the updated repro anyway? I added a real subscription to interval, which is not being printed out, even though it lives on after leaving the test page.

from observable-profiler.

awerlang avatar awerlang commented on May 23, 2024

Also, the number of reported subscriptions/printed lines does not seem to match:
Current subscriptions (including indirect/nested): 5
//Lines of output: 3

Indirect subscriptions are omitted by default. printSubscribers({ reportInnerSubscriptions: true }) should report all of them.

Can you please look at the updated repro anyway? I added a real subscription to interval, which is not being printed out, even though it lives on after leaving the test page.

Using the router recipe, subscription tracking begins when the routed component is activated i.e. after its construction. Besides I advise never to subscribe in constructors. I moved the subscription to ngOnInit as it's a better practice, then the leak is reported to console.

The router recipe is intended to catch leaks as fast and localized as possible. Once you're done with router tests, use the bootstrap recipe, which would catch many more leaks, including work done outside router.

Happy bug fixing! ;)

from observable-profiler.

awerlang avatar awerlang commented on May 23, 2024

Hello, have you got time to look at it again?

Cheers

from observable-profiler.

spiko-md avatar spiko-md commented on May 23, 2024

Hi, I tried again and now that I understand how the tool works I think you can close this issue. I get reports about several unclosed subscriptions, but I think most are cleaned up since I don't see them on further requests.
Thank you

from observable-profiler.

Related Issues (2)

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.