[platform-server] SSR for Standalone Component: bootstrapApplication have memory leaks
See original GitHub issueWhich @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:
- checkout master then:
pnpm install
pnpm dev:ssr
to servenodemon --inspect=localhost:9236 dist/server/main.js
to inspect
Then I start it and make a heap snapshot. it’s fine.
Open dev tools for Node.js to inspect, Go to memory tab, search module
keyword
first-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.
- checkout master then:
pnpm install
pnpm dev:ssr
to servenodemon --inspect=localhost:9236 dist/server/main.js
to inspect
go 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
)
Angular CLI: 14.0.2
Node: 16.13.1
Package Manager: pnpm 7.1.5
OS: win32 x64
Angular: 14.0.3
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1400.2
@angular-devkit/build-angular 14.0.2
@angular-devkit/core 14.0.2
@angular-devkit/schematics 14.0.2
@angular/cli 14.0.2
@nguniversal/builders 14.0.1
@nguniversal/common 14.0.1
@nguniversal/express-engine 14.0.1
@schematics/angular 14.0.2
rxjs 7.5.5
typescript 4.7.4
Anything else?
I’m running the standalone SSR version in my production version. Current work around is restart the server 😄
Issue Analytics
- State:
- Created a year ago
- Comments:15 (6 by maintainers)
Top GitHub Comments
@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.
@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 ❤️