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

BaseComponent is causing memory leaks #17645

Open
4 tasks
sean-dp opened this issue Feb 12, 2025 · 0 comments
Open
4 tasks

BaseComponent is causing memory leaks #17645

sean-dp opened this issue Feb 12, 2025 · 0 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@sean-dp
Copy link

sean-dp commented Feb 12, 2025

Describe the bug

A memory leak has been occurring in BaseComponent since Primeng18, and it appears to be affecting all components that inherit from BaseComponent.
This is happening because the ThemeService being called on BaseComponent's _themeChangeListener is not being released.

    _themeChangeListener(callback = () => {}) {
        Base.clearLoadedStyleNames();
        ThemeService.on('theme:change', callback);
    }

Pull Request Link

#17644

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://stackblitz.com/edit/promeng-memory-leak-problem?file=src%2Fmain.ts

Environment

PrimeNG 19, Angular 19

Angular version

v19.0.6

PrimeNG version

v19

Node version

v18.20.3

Browser(s)

Chrome, Edge

Steps to reproduce the behavior

This can be verified in all components using BaseComponent.
It is particularly easy to confirm when using components with virtual scrolling such as Scroller, TreeTable, and Table.
If you continue to repeatedly scroll with virtual scrolling, the project's memory usage gradually increases. Details can be confirmed by taking a heap snapshot in the browser.

Expected behavior

Ensure that ThemeService is properly handled and memory is released when the component is destroyed.

@sean-dp sean-dp added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant