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

[Bug Report][3.7.1] Memory leak with VOverlay and VDataTable #20422

Closed
lebinhchieu opened this issue Sep 4, 2024 · 3 comments
Closed

[Bug Report][3.7.1] Memory leak with VOverlay and VDataTable #20422

lebinhchieu opened this issue Sep 4, 2024 · 3 comments
Assignees
Labels
C: VOverlay VOverlay T: bug Functionality that does not work as intended/expected
Milestone

Comments

@lebinhchieu
Copy link

Environment

Vuetify Version: 3.7.1
Vue Version: 3.5.0
Browsers: Google Chrome
OS: Windows

Steps to reproduce

  1. Install packages, build & preview
  2. Access home page via Chrome
  3. Open memory in devtools & take a snapshot
  4. Open the snapshot, filter TestObject => Nothing shows
  5. Click Overlay or Data Table link (both pages create a TestObject instance)
  6. Click Back to home button in the Overlay or Data Table link to back to home
  7. Take a new memory snapshot
  8. Filter TestObject => a record shows

Expected Behavior

TestObject should be removed

Actual Behavior

TestObject is still there after backing to home
image

Reproduction Link

https://github.com/lebinhchieu/vuetify-memory-issue

@vuetifyjs vuetifyjs deleted a comment Sep 4, 2024
@CyberNick2025
Copy link

Hey,
After receiving several complaints that our web application keeps hanging up after some time, we also started looking for the cause and came across v-dialog.

Thanks to @peter-gy and his bug report #18880. By reading his comments I was able to try out the approach he proposed to solve an similar issue. 🎉

I used function getEventListeners(document) in the developer console of Chrome to find out if there is an event listener that is not removed after closing the dialog. I was able to find out that the event listener for the focusin event is not removed cleanly and I am now quite sure that this is the cause of the memory leak.

I tried to locally edit the VDialog.mjs to resolve the issue. The event listener is added here:

if (IN_BROWSER) {
      watch(() => isActive.value && props.retainFocus, val => {
        val ? document.addEventListener('focusin', onFocusin) : document.removeEventListener('focusin', onFocusin);
      }, {
        immediate: true
      });
    }

After adding the following code to the file and restarting the development server I was able to resolve the memory leak:

onBeforeUnmount(() => {
      document.removeEventListener('focusin', onFocusin)
    })

As this is the first time I added a comment to a GitHub project, I hope my comment was helpful 😄

@lebinhchieu
Copy link
Author

Thanks for your response @CyberNick2025

Hope Vuetify team could fix the issue soon

@CyberNick2025
Copy link

CyberNick2025 commented Oct 24, 2024

Hi @lebinhchieu ,
one thing that may helps you in the meantime is to set the property retain-focus of the v-dialog to false in your code:
:retain-focus="false". If you do not need retain-focus to be set to true it may works as a workaround for you.

https://vuetifyjs.com/en/components/dialogs/#props-retain-focus

@KaelWD KaelWD added T: bug Functionality that does not work as intended/expected C: VOverlay VOverlay labels Oct 26, 2024
@KaelWD KaelWD closed this as completed in a72df88 Nov 3, 2024
@KaelWD KaelWD added this to the v3.7.x milestone Nov 3, 2024
@KaelWD KaelWD self-assigned this Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VOverlay VOverlay T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

No branches or pull requests

4 participants
@lebinhchieu @KaelWD @CyberNick2025 and others