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
Memory: Widgets with "target" or "trigger" leak #11700
Labels
⚡ performance
Performance related issue or enhancement
Comments
This is just a workaround not the final solution but this fixes it for all components. $(document).ready(function () {
for (key in PrimeFaces.widgets) {
let widget = PrimeFaces.widgets[key];
if (widget && widget.target instanceof jQuery) {
widget.target.off("remove.widget").on("remove.widget", function () {
PrimeFaces.detachedWidgets.push(widget.widgetVar);
});
}
if (widget && widget.trigger instanceof jQuery) {
widget.trigger.off("remove.widget").on("remove.widget", function () {
PrimeFaces.detachedWidgets.push(widget.widgetVar);
});
}
}
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was a major cause of the leak at my client. Any element that has a
trigger/target
element should remove its widget when itstarget/trigger
is removed from the DOM.Reproducer
This is easy to replicate using the showcase:
$('#tb').remove();
p:sticky
still has a JS reference to it in itstarget
property which causes the garbage collector to never collect it.PrimeFaces.destoyDetachedWidgets()
The 6 buttons, all their DIVS and everything inside the toolbar is now being held in memory as "Detached DOM" elements.
The text was updated successfully, but these errors were encountered: