Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 17 @for has memory leak #55316

Closed
btiller123 opened this issue Apr 12, 2024 · 2 comments
Closed

Angular 17 @for has memory leak #55316

btiller123 opened this issue Apr 12, 2024 · 2 comments
Labels
area: core Issues related to the framework runtime core: control flow Issues related to the built-in control flow (@if, @for, @switch) memory leak Issue related to a memory leak needs reproduction This issue needs a reproduction in order for the team to investigate further
Milestone

Comments

@btiller123
Copy link

btiller123 commented Apr 12, 2024

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

I have several lists of size 20 - 100 using mat-select that are auto refreshed every 30 seconds with a small amount of new data added each time. When using @for, after several auto-refreshes the browser begins to exponentially increase ram usage to the point that the web page becomes inoperable. When I replace @for with the previous *ngFor the problem goes away. I've upgraded to package 17.3.4 and the problem still exists.

<mat-select class="selection-text" (selectionChange)="onAppContextSelectionChange($event)"(closed)="onAppContextDropdownClosed()"
                     formControlName="appContextControl" placeholder="Select context(s)"  panelWidth="fit-content" multiple>
                 <mat-select-trigger>
                      {{form.controls['appContextControl'].value?.[0] || ''}}
                     <span *ngIf="(form.controls['appContextControl'].value?.length || 0) > 1" class="additional-selection">
                      (+{{(form.controls['appContextControl'].value?.length || 0) - 1}} {{form.controls['appContextControl'].value?.length === 2 ? 'other' : 'others'}})
                      </span>
                 </mat-select-trigger>
 <!--- this @for causes memory leak -->
                  @for(context of appContextNameList; track context.name) {
                   <mat-option [disabled]="context.disabled" class="selection-text"[value]="context.name">{{context.name}}</mat-option>
                  }
<!-- problem goes away when I replace @for with this loop control 
                 <mat-option *ngFor="let context of appContextNameList" [disabled]="context.disabled" class="selection-text"[value]="context.name">{{context.name}}</mat-option>
 -->
</mat-select>

Please provide a link to a minimal reproduction of the bug

See above

Please provide the exception or error you saw

See above

Please provide the environment you discovered this bug in (run ng version)

No response

Anything else?

The ts code is using promises to get various lists and process data in the order needed. That said I had no issues with function/memory until I migrated the html to use the latest loop syntax @for.

@atscott atscott added area: core Issues related to the framework runtime core: control flow Issues related to the built-in control flow (@if, @for, @switch) labels Apr 12, 2024
@ngbot ngbot bot modified the milestone: needsTriage Apr 12, 2024
@JeanMeche
Copy link
Member

Hi, could you provide a working reproduction of this issue, either via a github repo or a stackblitz repro ?

@JeanMeche JeanMeche added the memory leak Issue related to a memory leak label Apr 12, 2024
@JoostK JoostK added the needs reproduction This issue needs a reproduction in order for the team to investigate further label Apr 12, 2024
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Apr 12, 2024
@JoostK
Copy link
Member

JoostK commented Apr 28, 2024

Closing as we haven't received a reproduction. Please open a new issue (or comment with a repro if this issue hasn't been autoclosed yet) with more information to help us investigate.

@JoostK JoostK closed this as not planned Won't fix, can't repro, duplicate, stale Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime core: control flow Issues related to the built-in control flow (@if, @for, @switch) memory leak Issue related to a memory leak needs reproduction This issue needs a reproduction in order for the team to investigate further
Projects
None yet
Development

No branches or pull requests

4 participants