I am trying to create a dynamic component. Here is the sample in plunker. http://embed.plnkr.co/EVFglgkp24hkRkpxrEGe/ Everything is working but there is a memory leak.
Here is the github ticket https://github.com/angular/angular/issues/19997
Dynamically created components are getting destroyed, but the component which created the dynamic component is not getting destroyed. In other words, The component which compiled the dynamic component is not getting destroyed.
In the above example, if we navigate back and forth between "Home" and "Dynamic Page" and take a snapshot of memory in chrome, you can see that the components suppose to be destroyed are still there as depicted below.
For the testing purpose, I even tried commenting the bellow lines, but still the issue exists.
let injector = ReflectiveInjector.fromResolvedProviders([], this.vcRef.parentInjector);
let ngMdlRef = ngMdlFac.create(injector);
let cmpFactory = ngMdlRef.componentFactoryResolver.resolveComponentFactory(DynamicHtmlComponent);
this.cmpRef = this.vcRef.createComponent(cmpFactory);
The moment I call
this.compiler.compileModuleAsync
The creator component is not getting destroyed at all. until then there is no issue.
Can you please someone help on this. Thank you in advance.