Skip to content

Root effects leak memory in dev mode #65265

@fl-mueller

Description

@fl-mueller

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

I am using the first demo from https://material.angular.dev/cdk/scrolling/overview.
When you conditionally show and hide the scroll viewport, it is not correctly removed by the garbage collector.

Image

Seems somehow connected to:
https://github.com/angular/components/blob/main/src/cdk/scrolling/virtual-scroll-viewport.ts#L214

Is this still bound to the application refs effects scheduler?

Reproduction

StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-luexm4f1?file=src%2Fmain.ts
Steps to reproduce:

  1. Click the toggle button
  2. open the dev tools and create a snapshot of the heap
  3. look for "cdk-virtual-scroll-viewport"
  4. its detached and retained

Expected Behavior

After removal from the dom, the cdk-virtual-scroll-viewport should not be retained in memory.

Actual Behavior

After removal from the dom, the cdk-virtual-scroll-viewport is retained as detached in memory.

Environment

ng version

Angular CLI: 20.3.9
Node: 20.19.1
Package Manager: npm 10.8.2
OS: linux x64

Angular: 20.3.10
... common, compiler, compiler-cli, core, forms
... platform-browser, router

Package Version

@angular-devkit/architect 0.2003.9
@angular-devkit/core 20.3.9
@angular-devkit/schematics 20.3.9
@angular/build 20.3.9
@angular/cdk 20.2.12
@angular/cli 20.3.9
@schematics/angular 20.3.9
rxjs 7.8.2
typescript 5.9.3
zone.js 0.15.1

Image

Metadata

Metadata

Assignees

Labels

area: coreIssues related to the framework runtimecore: reactivityWork related to fine-grained reactivity in the core frameworkmemory leakIssue related to a memory leak

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions