core: Memory leak

Vue version

3.5.4

Link to minimal reproduction

http://cant.insert.code/commercial_project

Steps to reproduce

The problem started to appear in Vue 3.5.* (including version 3.5.4). There are no problems in version 3.4.38. In my case, the approximate source of the problem is an active websocket connection.

What is expected?

No memory leak

What is actually happening?

After establishing a socket connection from which data is coming, the memory grows infinitely. Moreover, the more socket connections, the more the memory grows without stopping. With 10 connections in 5-10 minutes, the heap size consumption is more than 3 GB. An example of how a leak starts after the application starts: image

At the same time, taking memory snapshots is very difficult because the snapshot formation often gets stuck at the stage (Building dominator tree). image

If you still manage to take a memory snapshot, it turns out that the preliminary cause is deps (I may be wrong). image

I want to clarify that in case of a leak: DOM Nodes - do not change. JS Event Listeners - do not change.

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12400
    Memory: 13.66 GB / 31.77 GB
  Binaries:
    Node: 18.12.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Electron": 32.0.1
  Browsers:
    Chrome: 128.0.6613.120
  npmPackages:
    vue: ^3.5.4 => 3.5.4

Any additional comments?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 22 (9 by maintainers)

Most upvoted comments

@rxdiscovery try v3.5.7 by the way. We fixed some memory leaks yesterday.

I’ve already done the test, but unfortunately the problem persists.

@edison1105 I’m currently analyzing the source code of Quasar’s “QSelect”, to reproduce something similar in Vue, then I’ll be able to give you a code without any dependencies.

Might be related to c74bb8c2d

@rxdiscovery can you try the commit release here (set vue dependency in package.json to https://pkg.pr.new/vue@cbc39d5) to see if it works?

Still unable to reproduce

  • in Chrome incognito mode, ensure there are no browser extensions
  • manually collect garbage
  • JS heap size, DOM Nodes, JS event listeners. Their numbers will not continue to grow.

image

I also deliberately launched the demo in incognito mode. As you can see from the screenshot, the memory is gradually growing from snapshot to snapshot. Deps is also growing and is not cleared. Even deliberately calling the garbage collector from devtools does not improve the situation.

image