Skip to content

[platform-server] SSR for Standalone Component: bootstrapApplication have memory leaks  #46473

@hiepxanh

Description

@hiepxanh

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:

  • checkout master then: pnpm install
  • pnpm dev:ssr to serve
  • nodemon --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
image

first-time load home page:
image
load home page at second time:
image

load home page at 20th times:
image

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 serve
  • nodemon --inspect=localhost:9236 dist/server/main.js to inspect

go home page and f5 for 6 times:
image

go home page and f5 for more 5 times:
image

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 :D

Metadata

Metadata

Assignees

Labels

P2The issue is important to a large percentage of users, with a workaroundarea: serverIssues related to server-side renderingbugcross-cutting: standaloneIssues related to the NgModule-less worldmemory leakIssue related to a memory leakstate: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions