kit: Memory leak?
Describe the bug
I am seeing the memory usage of my SvelteKit app, running with the Node adapter, going up and up. I’m not sure how the server’s memory usage can keep increasing, all the svelte stores for example are only used in the browser, and other than that the server requests should be stateless, right?
See https://discord.com/channels/457912077277855764/1081891569390583898 for a discussion about this.
Reproduction
As far as I know, any project will show this problem.
Create a new skeleton project. No need to add TypeScript, Prettier, ESLint or anything else.
npm create svelte@latest repro
cd repro
npm i
npm run build
npm run preview
Open http://127.0.0.1:4173/, open the activity monitor (on macOS) or top
or whatever else to see memory usage of the Node process, and refresh the webpage a whole bunch of times. You’ll see the memory go up. It’s slow to increase with such a simple skeleton project so you might need to refresh a whole bunch of times, but it does go up.
In my moderately popular website it goes up by about 300 MB per day.
Logs
No response
System Info
System:
OS: macOS 13.2.1
CPU: (10) arm64 Apple M1 Max
Memory: 274.47 MB / 32.00 GB
Shell: 3.6.0 - /opt/homebrew/bin/fish
Binaries:
Node: 16.17.0 - ~/Library/pnpm/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.15.0 - ~/Library/pnpm/npm
Browsers:
Chrome: 111.0.5563.64
Edge: 110.0.1587.69
Firefox: 110.0.1
Safari: 16.3
npmPackages:
@sveltejs/adapter-auto: ^2.0.0 => 2.0.0
@sveltejs/kit: ^1.5.0 => 1.11.0
svelte: ^3.54.0 => 3.56.0
vite: ^4.0.0 => 4.1.4
Severity
serious, but I can work around it
Additional Information
I have to restart my Node server once in a while or the server just runs out of memory.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 5
- Comments: 29 (14 by maintainers)
Can we fix this asap ? Our production server capacity is lost by more than 100%. Basically we need to have more than twice the servers and the perf has become really bad as well. We have no choice other than to pin down adapter node. Can this issue get more traction ?
I’ve deployed a new version, will keep an eye on the memory usage and report back.
This was the last 30 days, for reference:
I think the leak is indeed solved 🎉 At first the memory increased by about 15 MB, but it’s been stable at ~60 MB for about 12 hours now. Huge difference.