-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
There appears to be a memory leak in our Angular application. After each server-side rendered request, the generated HTML string is not being properly garbage-collected and remains in the server's memory. This causes the Node.js server's memory consumption to grow linearly with each page refresh, eventually leading to a crash.
The issue is reproducible in a minimal application that uses TransferState to pass a large array of data from the server to the client.
https://github.com/alaa-kh-fe/memory-test
git clone https://github.com/alaa-kh-fe/memory-test.git
cd memory-test
npm install
ng build --configuration=production --prerender=false
node --inspect dist/memory-test/server/server.mjs
Please provide a link to a minimal reproduction of the bug
https://github.com/alaa-kh-fe/memory-test
Please provide the exception or error you saw
Open Google Chrome and navigate to chrome://inspect. Connect to the running Node.js process.
Go to the Memory tab and take a heap snapshot.
In a separate browser tab, open http://localhost:4000/memory-01 and refresh the page 5-10 times.
Return to the inspector and take a second heap snapshot.
Compare the two snapshots. You will see multiple instances of the application's <!DOCTYPE html>... string retained in memory, each corresponding to a page request.

Please provide the environment you discovered this bug in (run ng version
)
Angular version: 19.2.0
Node.js version: 22.16.0
Operating System: Windows
Anything else?
No response