-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
All components: Memory leak #6715
Labels
performance
Issue is performance or optimization related
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
Comments
using slice and map together is slow... it will not affect the memory leak but this could be better so use |
Thanks a lot for your report! I'll check and get back to you. |
I'm seeing the same problem. Version 4.0.7 Removing PrimeVue components causes the leak to disappear or become negligible |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
performance
Issue is performance or optimization related
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Describe the bug
Memory leak : callbacks in EventBus are never removed
Description
A memory leak issue exists due to the
EventBus
. Some callback functions registered to theEventBus
are never removed, causing unused callbacks to accumulate in memory over time. This leads to increased memory usage, especially in applications where components with registered callbacks are frequently added and removed.Steps to Reproduce
Before
After
Expected Behavior
When a component is destroyed or unmounted, the associated callbacks registered to the
EventBus
should be removed automatically.Actual Behavior
Callbacks registered with
EventBus.on()
are never removed, even after the component is unmounted. This causes memory leaks.Examples of Affected Code
The following code samples demonstrate instances within PrimeVue where callbacks are registered to
EventBus
without being properly removed, contributing to memory leaks:BaseDirective.js
In the
BaseDirective.js
file, the following code snippet shows howconfig
andconfig.ripple
watchers register listeners onPrimeVueService
without cleanup:Similarly,
_loadStyles
registers listeners for theme changes but does not remove them:BaseComponent.vue
In
BaseComponent.vue
, thedt
watcher registers a _themeChangeListener that is never removed:There are additional instances throughout the code with similar issues, where listeners are registered but not removed after component unmounting.
Proposed Solution
Remove callbacks from
EventBus
when the component is unmounted or destroyed.This issue is a generalization of the memory leak reported in issue #6223
Reproducer
https://primevue.org
PrimeVue version
4.2.0
Vue version
4.x
Language
TypeScript
Build / Runtime
Vue CLI App
Browser(s)
No response
The text was updated successfully, but these errors were encountered: