question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 😄

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
AndrewKushnircommented, Jun 29, 2022

@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.

2reactions
hiepxanhcommented, Jun 25, 2022

@AndrewKushnir thank you, sir. There is no sign of the memory leak anymore. image

After routing about 100 routes, the memory is still stable. everything is fine. I think I can use it now ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hunting memory leaks in a server side rendered React ...
Our memory leak was caused by reselect and with the bad usage of styled-components, both problems were found by using Chrome DevTools. Backstory....
Read more >
How Angular SSR works under the hood - source code ...
This causes a memory leak by itself. If your SSR never ends and you have no clue which pending async task causes it,...
Read more >
@angular/elements | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
angular/core - UNPKG
'importProvidersFrom' can't be used for component providers.`); ... On IE the function doesn't have its own `name` property, but it takes it from....
Read more >
Leaflet.js + Vue.js - Memory Leak when Navigating between ...
I'm not a vue expert, but I'm pretty sure the problem is that you are not destroying the leaflet map correctly. You have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found