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

Closed
4 tasks
sean-dp opened this issue Feb 12, 2025 · 0 comments · Fixed by #17644
Closed
4 tasks

BaseComponent is causing memory leaks #17645

sean-dp opened this issue Feb 12, 2025 · 0 comments · Fixed by #17644
Labels
LTS-PORTABLE Issue's fix will be ported to supported LTS versions Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@sean-dp
Copy link
Contributor

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
@cetincakiroglu cetincakiroglu added this to the 19.0.8 milestone Feb 24, 2025
@cetincakiroglu cetincakiroglu modified the milestones: 19.0.8, 18.0.5-lts Feb 24, 2025
@github-project-automation github-project-automation bot moved this to Review in PrimeNG Feb 24, 2025
@cetincakiroglu cetincakiroglu modified the milestones: 18.0.5-lts, 19.0.8 Feb 24, 2025
@cetincakiroglu cetincakiroglu removed the status in PrimeNG Feb 24, 2025
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working LTS-PORTABLE Issue's fix will be ported to supported LTS versions and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Feb 24, 2025
@cetincakiroglu cetincakiroglu linked a pull request Feb 24, 2025 that will close this issue
@github-project-automation github-project-automation bot moved this to Done in PrimeNG Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS-PORTABLE Issue's fix will be ported to supported LTS versions Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants