question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory leak in QSelect component with "use-input" prop enabled

See original GitHub issue

What happened?

“use-input” prop on QSelect, wrapped in QDialog, produces a memory leak.

What did you expect to happen?

“use-input” prop on QSelect, wrapped in QDialog, doesn’t produce a memory leak.

Reproduction URL

https://jsfiddle.net/dmytro_svyrydenko/jx1trcLv/14/

How to reproduce?

  1. Go to the provided reproduction link.
  2. Go to the “Memory” tab, and select the second VM instance, where the code result is running. Make a Heap Snapshot. It will be the initial value.
  3. Click on the “TOGGLE” button.
  4. Focus on any field so that the dropdown with options is opened.
  5. Close the dropdown, and click “TOGGLE” to hide elements.
  6. Go to the “Memory” tab, and select the second VM instance, where the code result is running.
  7. Make Heap Snapshot (Garbage Collection is called automatically, but you can force it manually if you wish).
  8. Filter both initial and newly created Snapshots by “Detached”.
  9. See the difference in Detached elements on the page. Each repetition of steps 2-4 just increases the number of detached nodes.

Happens on both UMD and Vue CLI plugin versions. Didn’t test others.

Flavour

UMD

Areas

Components (quasar)

Platforms/Browsers

Firefox, Chrome, Safari, Microsoft Edge

Quasar info output

Operating System        Darwin(22.1.0) - darwin/x64
NodeJs                  12.18.3

Global packages    
  NPM                   6.14.6
  yarn                  1.16.0
  @quasar/cli           1.3.2
  @quasar/icongenie     Not installed
  cordova               Not installed

Relevant log output

No response

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rstoenescucommented, Nov 1, 2022

Yes.

1reaction
rstoenescucommented, Nov 1, 2022

More findings:

  1. There are no detached elements when devtools is not opened (and never was opened for the respective page). So basically this is a non-issue in production. Tested with Edge (Chromium & Blink based, not perfectly equivalent to Chrome) and its “Detached Elements” feature in devtools (+ forced GC, important!).
  2. Just be more accurate with the methodology used to test (the previous example kept references to btn and root elements):
<!DOCTYPE html>
<html>
  <body>
    <div id="root">
      <button id="btn">Click me</button>
      <input>
    </div>

    <script>
      function fn () {
        document.getElementById('btn').removeEventListener('click', fn)
        document.getElementById('root').remove()
      }

      document.getElementById('btn').addEventListener('click', fn)
    </script>
  </body>
</html>

It DOES matter if there is an input element (that got focused!). When the previously focused input element gets removed and devtools was opened then a bug in chromium hinders GC to do its job fully. Eventually, GC will kick in, but definitely not immediately.


Conclusion: At some point, this will get fixed in the Chromium/Blink engine. But we really can’t do anything about it in Quasar. But it seems to not affect a production environment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory leak with component with input with v-model #10004
I can confirm this happens in Chrome 74. When trying to replicate this in Safari, I cannot even see any Vue related objects...
Read more >
Input event causing memory leak - Vue.js - Stack Overflow
It relates to having a text input element and triggering an @input event whenever text is entered. const Child = { methods: {...
Read more >
How to fix the React memory leak warning - DEV Community ‍ ‍
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your...
Read more >
(The only proper) PDO tutorial - Treating PHP Delusions
Note that this method is memory-friendly, as it doesn't load all the resulting rows in the memory but delivers them one by one...
Read more >
@elastic/eui | Yarn - Package Manager
The Elastic UI Framework is a collection of React UI components for quickly building user interfaces at Elastic.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found