Skip to content

Memory Leak in BaseComponent #19249

@LoaderB0T

Description

@LoaderB0T

Describe the bug

3 months ago, a previously fixed memory leak in the BaseComponent of all primeng controls was reintroduced.

This leads to raising memory & degraded performance over time, especially in large applications.

Pull Request Link

#19250

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

No response

Reproducer

https://primeng.org (can be reproduced everywhere, follow repro stept)

Environment

The (at the time of writing) latest main branch has the issue and the released v21 version aswell.
The issue was reintroduced here: 9b5c3c7#diff-315219ce5e29cd6185c317544d0a096d9f46f310d322405400a1fdd72f0737f8

Angular version

21.0.5

PrimeNG version

v21

Node version

No response

Browser(s)

No response

Steps to reproduce the behavior

The issue can be easily reproduced on the primeng docs page.

My repro steps:

  1. serve the app locally (for unobfuscaded code)
  2. open the docs at http://localhost:4200/colorpicker
  3. reload the page for clean memory
  4. open the dev tools
  5. navigate to the memory in dev tools and force a garbage collection
  6. create a heap snapshot
  7. in the primeng docs navigate to the datepicker section, wait until it has loaded & then navigate back to the color picker
  8. in the devtools force anther garbace collection
  9. take another heap snapshot
  10. compare snapshot one with two (objects allocated between snapshot 1 and snapshot 2)
  11. Search for "date"

The result will show 33 retained instances of the datepicker component, including their DOM nodes.

Image

Expected behavior

With my fix, no component instances are retained anymore:

Image

Metadata

Metadata

Assignees

Labels

LTS-PORTABLEIssue's fix will be ported to supported LTS versionsType: BugIssue contains a bug related to a specific component. Something about the component is not working

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions