How to unload modules/components in angular2?

1,338 views
Skip to first unread message

Kumarjit Chakraborty

unread,
Apr 23, 2017, 6:48:10 AM4/23/17
to Angular and AngularJS discussion
I am very new to angular 2 and I am having problems with unloading modules and components. Below is my problem description:

  • trying to built a large SPA containing like 600-700 pages/components.
  • using webpack for the project
  • structuring the project like:
    • main module
      • child module a
        • page component a1
        • page component a2
        • ...
        • page component aN
      • child component a
      • child module b
        • page component b1
        • page component b2
        • ...
        • page component bN
      • child component b
    • main component

Problem I am facing - When I am jumping from a page of child module a to a page of child module b only root component child module a, i.e. child component a, is getting destroy not the page components a1, a2, a3 ... aN. I can see those present in heap snapshots. This is bloating the memory.


Can anyone suggest me how to unload the entire module along with the components from memory? Or what I am doing wrong here?

Sander Elias

unread,
Apr 24, 2017, 10:25:43 AM4/24/17
to Angular and AngularJS discussion
Hi Kumarjit,

Currently, it is not possible to unload modules. I have put it on the agenda of the core team, but it's not that high on the priority list. (yet!) The only way to flush memory is a page-reload. The easiest way to do that is using a href instead of a routerlink to navigate between certain parts of your application.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages