Details
-
Bug
-
Resolution: Fixed
-
Neutral
-
1.3.3
-
None
-
node v16.15.0
-
Empty show more show less
-
DevX 35, DevX 36
-
5
-
Yes
Description
Steps to reproduce
- Clone the spa minimal demos repository: https://git.magnolia-cms.com/scm/demos/minimal-headless-spa-demos.git
Follow the setup instructions for the Angular Universal demo, so that you have a page available at http://localhost:4200/angular-universal-minimal: https://git.magnolia-cms.com/projects/DEMOS/repos/minimal-headless-spa-demos/browse
Restart the SPA with node.js in debug / profiling mode
Stop the `dev:ssr` run
Run the following command from the angular-universal-minimal directory: `node --trace-gc --inspect-brk dist/angular-universal-minimal/server/main.js`
Open Chrome and type `about:inspect` in the address bar
Click the "inspect" link on the remote target `dist/angular-universal-minimal/server/main.js` in the Devices tab
A DevTools window opens for the Node server process
Resume script execution
Load the page (http://localhost:4200/angular-universal-minimal) repeatedly - about 100 times produces a noticeable result
Take a heap snapshot from the DevTools window of the Node server process, in the Memory tabExpand the `Object` tree branch
Screenshot of the heap view:

Link to a heap dump:
https://drive.google.com/file/d/1LhlKFrPNlWa-lp1psUIqhdF9GxTb4FEk/view?usp=sharing
Actual results
- There is one large object in the heap (16 MB for about 100 page loads) containing an array named `updatestate`, which contains callback functions. These function objects each hold a reference to an instance of the Magnolia `EditablePageComponent` as their `this` context.
- The `updatestate` array grows larger with every Angular Universal render, as callbacks are pushed to it in the constructor of `EditablePageComponent` (delegating to `PageEditorBridge`) but never cleared on Angular destroy events
- The references to `EditablePageComponent` can retain quite a bit of memory in the heap, as the components hold references to the entire Angular context
Expected results
- Objects used for a single Angular Universal render are not retained when the rendering is completed, resp. for the remainder of the server running time
- The instances of EditablePageComponent are properly garbage collected after an Angular Universal render
Workaround
No effective workaround found
Development notes
Checklists
Acceptance criteria
Attachments
Issue Links
- is related to
-
MGNLFE-465 editable page objects are created and never removed
-
- Open
-
-
MGNLFE-464 page editor bridge calls are not consistent
-
- Closed
-
1.
|
Implement |
|
Completed | Phong Le Quoc |
2.
|
Review |
|
Completed | Robert Šiška |
3.
|
PiQA |
|
Completed | Robert Šiška |
4.
|
QA |
|
Completed | Canh Nguyen |