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

Potential memory leak of vue-tsc --noEmit -w #1106

Closed
fi3ework opened this issue Mar 25, 2022 · 7 comments
Closed

Potential memory leak of vue-tsc --noEmit -w #1106

fi3ework opened this issue Mar 25, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@fi3ework
Copy link

fi3ework commented Mar 25, 2022

Reproduction

  1. pnpm create vite bug-vue-tsc
  2. select vue and vue-ts
  3. pnpm i vue-tsc@latest -D
  4. NODE_OPTIONS='--max_old_space_size=700' pnpm exec vue-tsc --noEmit -w
  5. Modify any code of App.vue and wait for the watch process response.
  6. Repeat step 5 for about 7 times and the process will OOM 🤔

FYI: I tried setting max_old_space_size to 2000 but still crash about 18 times of modification. Use htop to inspect I find the memory of the process keeps growing 🤔.

<--- Last few GCs --->

[2461:0x7f9d08008000]    36171 ms: Mark-sweep 697.9 (714.9) -> 696.7 (714.7) MB, 284.8 / 0.0 ms  (average mu = 0.128, current mu = 0.028) allocation failure scavenge might not succeed
[2461:0x7f9d08008000]    36416 ms: Mark-sweep (reduce) 699.0 (714.7) -> 698.6 (713.7) MB, 39.8 / 0.0 ms  (+ 145.5 ms in 31 steps since start of marking, biggest step 5.7 ms, walltime since start of marking 197 ms) (average mu = 0.182, current mu = 0.244) 

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1070a2a25 node::Abort() (.cold.1) [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
 2: 0x105d980f9 node::Abort() [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
 3: 0x105d9826f node::OnFatalError(char const*, char const*) [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
 4: 0x105f19787 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
 5: 0x105f19723 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
 6: 0x1060bae05 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
 7: 0x1060b978c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpaceÏ v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
 8: 0x1060c6030 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
 9: 0x1060c60b1 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
10: 0x106093147 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
11: 0x10644ad4e v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
12: 0x1067f4819 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/fi3ework/Library/Application Support/fnm/node-versions/v16.14.0/installation/bin/node]
13: 0x10b169ab7 
14: 0x10b1fa2e4 
15: 0x10b0f8099 
16: 0x10ac789e8 
17: 0x10b16ea97 
18: 0x10ad30528 
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command was killed with SIGABRT (Aborted): /Users/fi3ework/Downloads/test1/node_modules/.bin/vue-tsc --noEmit -w

Expected behavior

Do not leak memory.

System info

npx envinfo --system --npmPackages vue-tsc --binaries --browsers

  System:
    OS: macOS 12.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 543.25 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/Library/Caches/fnm_multishells/51303_1648175932312/bin/node
    Yarn: 1.22.18 - ~/Library/Caches/fnm_multishells/51303_1648175932312/bin/yarn
    npm: 8.3.1 - ~/Library/Caches/fnm_multishells/51303_1648175932312/bin/npm
  Browsers:
    Chrome: 99.0.4844.83
    Firefox: 98.0.2
    Safari: 15.4
  npmPackages:
    vue-tsc: ^0.33.7 => 0.33.7 

Package manager

pnpm@^6

@fi3ework fi3ework changed the title Potential memory leak of vue-tsc watch mode Potential memory leak of vue-tsc --noEmit -w Mar 25, 2022
@johnsoncodehk johnsoncodehk added the bug Something isn't working label Mar 25, 2022
@johnsoncodehk
Copy link
Member

OMG :(

@PatrickRose
Copy link

Realise this has been closed, but I'm still noticing exactly the same behaviour on my system (using a docker container).

$ sail npx envinfo --system --npmPackages vue-tsc --binaries --browsers

  System:
    OS: Linux 5.10 Ubuntu 22.04 LTS 22.04 LTS (Jammy Jellyfish)
    CPU: (4) arm64 unknown
    Memory: 5.28 GB / 7.75 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.15.1 - /usr/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.12.2 - /usr/bin/npm
  npmPackages:
    vue-tsc: ^0.38.1 => 0.38.1

Making a change to any file makes vue-tsc use 2% more memory, and it eventually hits an OOM.

@kevinvalk
Copy link

kevinvalk commented Jun 29, 2022

Like @PatrickRose mentioned, I am observing the same memory leaking behavior (running within docker container).

However, we are using the vite-plugin-checker to run vue-tsc. On every reload the memory consumption of the node process grows a bit and will go out of memory after a certain number of reloads. But it seems that more people in fi3ework/vite-plugin-checker#127 are suffering from this issue and it looks like the leak is occurring in vue-tsc.

Configuration:

...
export default defineConfig({
	plugins: [
		...
		checker({ vueTsc: true, enableBuild: false }),
	],
...
/app $ npx envinfo --system  --binaries --browser 

  System:
    OS: Linux 5.10 Alpine Linux
    CPU: (4) arm64 unknown
    Memory: 2.27 GB / 6.77 GB
    Container: Yes
    Shell: 1.35.0 - /bin/ash
  Binaries:
    Node: 16.15.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.11.0 - /usr/local/bin/npm

/app $ yarn list --pattern vue-tsc
yarn list v1.22.19
└─ vue-tsc@0.38.2

@johnsoncodehk
Copy link
Member

@PatrickRose, @kevinvalk Thank for the report, can you reproduce this problem without docker?

@johnsoncodehk johnsoncodehk reopened this Jul 7, 2022
@DhivinX
Copy link

DhivinX commented Jul 7, 2022

I think this is same problem:

Command:

vue-tsc --noEmit --watch

After multiple savings:

14:11:09 - File change detected. Starting incremental compilation...


<--- Last few GCs --->

[21016:000001B4A6E1F550]   142008 ms: Scavenge (reduce) 4065.8 (4142.8) -> 4064.9 (4143.1) MB, 3.1 / 0.0 ms  (average mu = 0.155, current mu = 0.001) allocation failure 
[21016:000001B4A6E1F550]   145183 ms: Mark-sweep (reduce) 4065.9 (4143.1) -> 4064.6 (4143.1) MB, 3172.4 / 0.0 ms  (average mu = 0.100, current mu = 0.022) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF7BE2C30AF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+112511
 2: 00007FF7BE252216 DSA_meth_get_flags+65542
 3: 00007FF7BE2530CD node::OnFatalError+301
 4: 00007FF7BEB84B6E v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF7BEB6F09D v8::SharedArrayBuffer::Externalize+781
 6: 00007FF7BEA1268C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468
 7: 00007FF7BEA1F339 v8::internal::Heap::PublishPendingAllocations+1129
 8: 00007FF7BEA1C30A v8::internal::Heap::PageFlagsAreConsistent+2842
 9: 00007FF7BEA0EF89 v8::internal::Heap::CollectGarbage+2137
10: 00007FF7BEA0D140 v8::internal::Heap::AllocateExternalBackingStore+2000
11: 00007FF7BEA31A76 v8::internal::Factory::NewFillerObject+214
12: 00007FF7BE764CB5 v8::internal::DateCache::Weekday+1797
13: 00007FF7BEC12541 v8::internal::SetupIsolateDelegate::SetupHeap+494417
14: 000001B4AA4B1D66
Warning: run-commands command "vue-tsc --noEmit --watch" exited with non-zero status code

System info:

System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
    Memory: 21.42 GB / 31.72 GB
  Binaries:
    Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.18 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.7.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (103.0.1264.44)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    vue-tsc: ^0.38.2 => 0.38.2

@lmcsu
Copy link

lmcsu commented Jul 8, 2022

The same.
After multiple savings it dies the same way.
OS: Ubuntu LTS

@kevinvalk
Copy link

@johnsoncodehk it is back again :'( exact same behavior as before and no significant changes in the setup.

Versions:

  System:
    OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (5) arm64 unknown
    Memory: 10.12 GB / 15.61 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 18.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.5.0 - /usr/local/bin/npm

yarn list v1.22.19
├─ vue-tsc@1.2.0
├─ vite-plugin-checker@0.5.6
└─ vite@4.1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants