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

Node process on Windows 11 consumes memory continuously, increasing about 3mb a second without being released #3976

Open
scotscoder opened this issue Jan 1, 2025 · 8 comments
Labels
Bug Something isn't working

Comments

@scotscoder
Copy link

Description

When running wails dev, the node process gradually consumes more and more memory, slowing down the host system. As observed, it increases by about 2.5 to 6mb per second on my system. GIF attached.

This happens with a completely new Svelte project. I will test it with other JS frameworks as well and update this issue.

Screen.Recording.2025-01-01.133325.mp4

To Reproduce

Use Windows 11.

  1. Init a new wails project using Svelte
  2. Run wails dev
  3. Watch the memory increase in Task Manager

Expected behaviour

Memory use should stay constant or "breathe" slightly up and down.

Screenshots

Screencap attached above

Attempted Fixes

Found a closed bug on the SvelteKit repo that mentioned a similar problem. It may be upstream from even that, but I'd rather check before we dive deeper.

System Details

# Wails
Version | v2.9.2

# System
┌─────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | Windows 10 Pro                                                                   |
| Version      | 2009 (Build: 26100)                                                              |
| ID           | 24H2                                                                             |
| Go Version   | go1.23.4                                                                         |
| Platform     | windows                                                                          |
| Architecture | amd64                                                                            |
| CPU          | AMD Ryzen 7 5800H with Radeon Graphics                                           |
| GPU 1        | NVIDIA GeForce RTX 3060 Laptop GPU (NVIDIA) - Driver: 32.0.15.5613               |
| GPU 2        | AMD Radeon(TM) Graphics (Advanced Micro Devices, Inc.) - Driver: 31.0.12002.1002 |
| Memory       | 16GB                                                                             |
└─────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌────────────────────────────────────────────────────────┐
| Dependency | Package Name | Status    | Version        |
| WebView2   | N/A          | Installed | 131.0.2903.112 |
| Nodejs     | N/A          | Installed | 22.12.0        |
| npm        | N/A          | Installed | 10.9.0         |
| *upx       | N/A          | Installed | upx 4.2.4      |
| *nsis      | N/A          | Installed | v3.10          |
└─────────────── * - Optional Dependency ────────────────┘

# Diagnosis
 SUCCESS  Your system is ready for Wails development!

Additional context

No response

@scotscoder scotscoder added the Bug Something isn't working label Jan 1, 2025
@scotscoder
Copy link
Author

I only noticed this issue because it started increasing my laptop fan when it reached 5GB of RAM consumed.

@scotscoder
Copy link
Author

This is after 30 minutes.

Screen.Recording.2025-01-01.142119_stripped.mp4

@scotscoder
Copy link
Author

It does seem to partially garbage collect periodically, just not very much.

@leaanthony
Copy link
Member

Sounds like an issue with Vite. Have you tried upgrading it?

@scotscoder
Copy link
Author

How do I upgrade Vite?

@jrb93
Copy link

jrb93 commented Jan 12, 2025

@scotscoder I also had this issue with vite using 25-32gb of ram out of 128gb, managed to fix it by setting this in vite.config.ts/js:

Edit:

Initially I thought this fixed the issue I was partially mistaken, it wasn't the setting at all it was a hot reload of the vite.config.ts/js that stops the cpu and ram usage, no other file edits seem to do the same only on the vite config.

vite.config.ts/js
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';

export default defineConfig({
  server:{
    hmr:{
      overlay: false
    }
  },
  plugins: [sveltekit()]
});

ref: vite.dev hmr docs

Its now only using around 600mb, even after 10mins and with updates.

Package versions:
"vite": "^6.0.7"
"svelte": "^5.17.3",
"@sveltejs/kit": "^2.15.2",
"@sveltejs/adapter-static": "^3.0.8",
"@sveltejs/vite-plugin-svelte": "^5.0.3",

To update your vite to the latest you will need to check your package manager documentation as npm/yarn/pnpm have slightly different commands for updating.

@jrb93
Copy link

jrb93 commented Jan 14, 2025

After a lot of testing I have narrowed it down to wails causing the issue in nodejs, best guess is the ipc or runtime injection. Tested on vanilla template and custom sveltekit frontend with skeleton.

wails dev
node.exe = CPU ~10%, RAM ~250mb growing ~3-6mb a sec.

pnpm dev (in frontend)
node.exe = CPU ~0%, RAM ~180mb doesn't grow

If you hot reload the vite config when using wails dev, the CPU% drops and RAM stops increasing does not decrease though. Inspecting the node process in devtools shows the vm only being ~100mb or less in size, which is vastly different from the task manager view.

Using x64dbg attached to node I observed alot of :
return to ntdll.RtlAllocateHeap+C24 from ntdll.RtlAllocateHeap+11F0
and
return to node.inflateValidate+675F from node.inflateValidate+2397C

If I attached to the build go exe and pause the node process still keeps increasing,

Edit: Doesn't cause this issue in wails3

@leaanthony
Copy link
Member

Thanks for taking the time to deep dive this. The only difference that I can think of between a dev and prod build is Go flags so I'm more convinced it's a vite HMR issue. Someone on this thread mentioned it stopped when turning off an error option in Vite stopped it. If your project is a simple html page what does it do?

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

3 participants