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

QCheckbox have a memory leaks issue. #17485

Closed
yeyuqh opened this issue Sep 5, 2024 · 2 comments
Closed

QCheckbox have a memory leaks issue. #17485

yeyuqh opened this issue Sep 5, 2024 · 2 comments

Comments

@yeyuqh
Copy link

yeyuqh commented Sep 5, 2024

What happened?

It’s not just QCheckbox; QRadio, QSpace, and other components also use this approach.

import { defineComponent, h } from 'vue'

 // This kind of implementation in the component creates a global VNode, which will not be collected by GC.
const prefixNode = h('span', { class: 'prefix' }, 'prefix') 

export default defineComponent({
  name: 'ListItem',
  props: ['index'],

  setup(props) {
    return () => (
      h('div', { class: 'item' }, [prefixNode, `Item ${props.index}`])
    )
  },
})

In some cases, this can cause the entire page’s DOM to not be collected by GC.

What did you expect to happen?

import { defineComponent, h } from 'vue'

export default defineComponent({
  name: 'ListItem',
  props: ['index'],

  setup(props) {
	const prefixNode = h('span', { class: 'prefix' }, 'prefix') // I believe it should be placed in the setup function.

    return () => (
      h('div', { class: 'item' }, [prefixNode, `Item ${props.index}`])
    )
  },
})

Reproduction URL

How to reproduce?

CleanShot 2024-09-05 at 16 14 45@2x
CleanShot 2024-09-05 at 16 21 14@2x

Clicking the Toggle button multiple times to show/hide it reveals that there are always 500 nodes that cannot be collected by GC.

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Components (quasar)

Platforms/Browsers

Chrome, Safari

Quasar info output

No response

Relevant log output

No response

Additional context

No response

Copy link

github-actions bot commented Sep 5, 2024

Hi @yeyuqh! 👋

It looks like you provided an invalid or unsupported reproduction URL.
Do not use any service other than Codepen, jsFiddle, StackBlitz, Codesandbox, and GitHub.
Make sure the URL you provided is correct and reachable. You can test it by visiting it in a private tab, another device, etc.
Please edit your original post above and provide a valid reproduction URL as explained.

Without a proper reproduction, your issue will have to get closed.

Thank you for your collaboration. 👏

@rstoenescu rstoenescu self-assigned this Sep 6, 2024
rstoenescu added a commit that referenced this issue Sep 6, 2024
@rstoenescu
Copy link
Member

Hi,

Thank you for creating this ticket and the reproduction setup!
You are indeed right. Seems like the GC doesn't clean up with those global nodes.

Fix will be available shortly in Quasar v2.16.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants