-
Notifications
You must be signed in to change notification settings - Fork 5
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
How to handle classes that are retained because they are extended by other classes? #35
Comments
I too am running into this issue. I have an addon with a service. I'm extending that service in the dummy app, then testing the subclass. The super class service is retained in the heap because it's the prototype of the subclass. |
@adc-mhaugen I still haven't come up with a solution to this problem. You could add the super classes to the ignoredClasses array in config, although I'm sure you'd rather not exclude that service from memory leak detection. Maybe you could find another pattern for testing the service that doesn't require you to subclass it? I'm sorry I don't have a more ideal solution here 😞 |
Thanks @steveszc, I'm using |
@steveszc Do you have any light reading on why this happens? Seems like a fundamental JS design problem with classes. I would think the garbage collector could identify the "unreachable objects"/not referenced object and mark + sweep them. |
@krisselden Mate I'm tagging you because you are super smart. |
@snewcomer I unfortunately haven't been able to find really any detailed information about why this is happening or how it could be avoided.
I have not found any additional information about why prototypes are never destroyed or whether there is a way to create a destroyable prototype. That guide was originally written by Trent Willis but I'm not sure what reference material he used. |
In the case where an app/addon defines a custom base class and then extends it...
The base class (
Car
in this example) will be retained in the heap by virtue of it being used as a prototype, even if the subclass (Sedan
in this example) is not itself retained, and even if no instances of the base class itself are ever created.The text was updated successfully, but these errors were encountered: