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
[platform-server] SSR for Standalone Component: bootstrapApplication have memory leaks #46473
Comments
Side note: this API is still experimental and should not be used in production. |
|
sorry, I was tempted. It just too smooth. I used jsdom too, but it event eat more ram than this one. |
|
I believe you're right about the leak. Digging into this just a little, it appears that |
|
Yes, I do, I also put a log while testing but do not see that log trigger on ngOnDestroy of appComponent |
This commit updates the `ApplicationRef` logic to trigger the destroy operation when an underlying platform is destroyed. This is needed to make sure all teardown processing is completed correctly to avoid memory leaks. Closes angular#46473.
This commit updates the `ApplicationRef` logic to trigger the destroy operation when an underlying platform is destroyed. This is needed to make sure all teardown processing is completed correctly to avoid memory leaks. Closes angular#46473.
|
@hiepxanh I've created a PR with a proposed fix, which ensures that the Note: this package is for testing purposes only and can not be used in production. Thank you. |
|
@AndrewKushnir yes sir, I'm very exciting, I'll test on this now |
|
@AndrewKushnir thank you, sir. There is no sign of the memory leak anymore. After routing about 100 routes, the memory is still stable. everything is fine. I think I can use it now <3 |
|
@hiepxanh thanks for testing the change! We'll follow our regular dev process (review, testing) and the fix will land in one of the upcoming patch versions (14.0.x). Thank you. |
This commit updates the `ApplicationRef` logic to trigger the destroy operation when an underlying platform is destroyed. This is needed to make sure all teardown processing is completed correctly to avoid memory leaks. Closes angular#46473.
This commit updates the `ApplicationRef` logic to trigger the destroy operation when an underlying platform is destroyed. This is needed to make sure all teardown processing is completed correctly to avoid memory leaks. Closes angular#46473.
|
@hiepxanh just wanted to let you know that we've released Angular v14.0.4, which contains the memory leak fix. Please try updating to the latest version and let us know if the problem is resolved. Thank you. |
|
Thank you that so fast, I'm going to do it now |
|
@AndrewKushnir I already test it, and I see the result is very good. Thank you for your effor |
|
@hiepxanh great, thanks for the update! |







Which @angular/* package(s) are the source of the bug?
platform-server
Is this a regression?
No
Description
ngModule version
I clone the Angular Universal repo version from angular:
pnpm installpnpm dev:ssrto servenodemon --inspect=localhost:9236 dist/server/main.jsto inspectThen I start it and make a heap snapshot. it's fine.

Open dev tools for Node.js to inspect, Go to memory tab, search
modulekeywordfirst-time load home page:


load home page at second time:
load home page at 20th times:

everything is fine and no leak. NgModule only have 2 instance
Standalone version
I upgrade the universal version of the standalone component, I'm going to make this on the universal repo, but first, it has a memory leak.
pnpm installpnpm dev:ssrto servenodemon --inspect=localhost:9236 dist/server/main.jsto inspectgo home page and f5 for 6 times:

go home page and f5 for more 5 times:

we get too many modules that are not clear and the heap memory goes "To infinity and beyond".
The ApplicationModule goes to x6 on 6 load pages, and x11 if you have 11 load pages.
Please provide a link to a minimal reproduction of the bug
https://github.com/hiepxanh/universal-test
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version)Anything else?
I'm running the standalone SSR version in my production version. Current work around is restart the server :D
The text was updated successfully, but these errors were encountered: