I created two pages first one is listing & the second one is details page with mat-tabs
. One of the tab contains web component(ViewComponent) created using angular/elements.
Following is the html for the details page.
<mat-tab-group>
<-- other tabs -->
<mat-tab *ngIf="tabName === viewComp">
<ng-template mat-tab-label>
<span>{{ label }}</span>
</ng-template>
<ng-container
*ngIf="loadedTabs.viewComp && apiSuccess"
>
<div *ngIf="testCondition">
<-- ViewComponent is web component created using angular/elements -->
<view-component
[data]="viewCompData"
></view-component>
</div>
</ng-container>
</mat-tab>
</mat-tab-group>
Now if I go back to listing page from details. ViewComponent still persist in memory following is screenshot of memory snapshot after garbage collection.
Now if I remove the div
element with testCondition
then in the retainers window its showing nameSpacesByHostElement
instead of collectedLeaveElements
.
Clicking on the top __ngContext__ in Detached HTMLElement@236587
jumps to following source - constructor of NgElementImpl
.
Please let me know how can I remove ViewComponent permanently from memory. Using Angular(v10.2) / material components(v10.2).