High Memory Usage in Node & Bun

justkira
HOBBY

25 days ago

i have 2 sevices like new has nothing just create a new sveltekit project and new hono project
Sveltekit is Using node-adpater
Hono is binary build using Bun

memory is Insanly high

On a Side note not sure if that mater im using Moonrepo which is a monorepo that Does optimized docker image well copying packages and stuff but highly dought it has anything to do with Bun or Node
i can link docker if that useful

im using Latest in both Node 24.6.0 and Bun 1.2.20

$10 Bounty

6 Replies

justkira
HOBBY

25 days ago

0ba69faf-5b6c-4a2c-9ca4-5617915a12b5


justkira
HOBBY

25 days ago

What is werid both have Same Usage like number wise which is quite werid


justkira
HOBBY

25 days ago

High Memory Usage in Node & Bun


allenshintani

1. Large Docker images - The built image itself might be too large2. Memory leaks - There could be memory leaks within the application3. Unoptimized images - Surprisingly common issue where images aren't being converted to efficient formats like WebP4. High replica count - Railway's minimum replica setting might be set too high5. TypeScript build issues - If using TypeScript, you might have:Redundant builds from sharing types between backend and frontendDuplicate build processesIn my experience, I was able to significantly reduce memory usage just by optimizing image sizes. What do you think about these possibilities?

justkira
HOBBY

24 days ago

Let me Clarify something the apps are super simple, sure maybe docker build is incorrect but i dont understand what do u mean with WebP , im talking about Docker images not images plus even if docker image is large it should large in file size not like memory usage.

Plus i don't want to sound rude but it feels like ai response

5. TypeScript build issues - If using TypeScript, you might have:

Redundant builds from sharing types between backend and frontend

Duplicate build processes

im suing bun for hono which build an optmized binary anyway


clashing
HOBBYTop 5% Contributor

24 days ago

Is the memory spike at a certain interval of code execution, during a particular function being executed, or is the pattern randomly distributed?

Can you provide the metrics graph's snippets of the past 7 days for both services (select a deployed service on Railway, & then go to the Metrics section)? This will allow us to show which service is consuming the memory.


clashing

Is the memory spike at a certain interval of code execution, during a particular function being executed, or is the pattern randomly distributed?Can you provide the metrics graph's snippets of the past 7 days for both services (select a deployed service on Railway, & then go to the Metrics section)? This will allow us to show which service is consuming the memory.

justkira
HOBBY

24 days ago

Well there is no spike its just simple deployed app there is no memory leak there is nothing it just a clean Hono backend and Sveltekit Project with no traffic thats ideal

Note thats a clean deploy so i have only 17H of data


lark

my bill

justkira
HOBBY

23 days ago

What does that have to do with my issue?


allenshintani

Sorry, I'm not very good at English, so I'm using AI to translate this. I'm the one talking about the content.Webp is talking about image file extensions. In a simple web app, if you don't compress the image size, the memory size will be quite large. If you're including png or jpeg images in your deployment, I suggest using webp.

justkira
HOBBY

23 days ago

Again its not realed to Images like png or webp its Docker Image not sure what AI u are using its super dumb there is no WEBP in the issue its again simple hono backend and sveltekit frontend DOCKER IMAGE


justkira
HOBBY

22 days ago

ok this is kinda werid as hell

1406956460486824000


justkira
HOBBY

22 days ago

there is no trafic or anything just a new deploy what is going on


22 days ago

according to the 'Public network traffic' graph it seems like there was ingress traffic happening at the same time the mem spiked


justkira
HOBBY

22 days ago

@Medim still even if there a network

why idle is 680mb


22 days ago

Is the memory footprint similar if this is running locally?


justkira
HOBBY

21 days ago

nope is on 180 usally

1407337451906662400


justkira
HOBBY

21 days ago

plus i just woke up and see this


justkira
HOBBY

21 days ago

i didn't change anything


@justkira - could provide provide a reproduction? I am on the Bun team. You can email me at conner@bun.com


20 days ago

@JustKira ^


justkira
HOBBY

20 days ago

?


justkira
HOBBY

20 days ago

?


20 days ago

Bun engineer replied to your thread asking for a reproduction
https://station.railway.com/questions/high-memory-usage-node-bun-f34a3603


justkira
HOBBY

20 days ago

ya i sent him an email


justkira
HOBBY

20 days ago

as he requested


20 days ago

Oh ok


justkira
HOBBY

20 days ago

or did i miss read it or soemthing


20 days ago

no, it's good


justkira
HOBBY

20 days ago

https://github.com/JustKira/moon-repo-railway-bun-memory-issue

let me link repo here for anyone want to try


justkira
HOBBY

20 days ago

this is funny i didn't change anything

1407755296830390500


justkira
HOBBY

16 days ago

umm this isn't funny any more what is going on

1409165391070236700


justkira
HOBBY

16 days ago

bun seems going full haywire


16 days ago

are you in contact with Connor from bun? have you provided them an MRE?


justkira
HOBBY

16 days ago

I did and also i send a email just now to see status update


justkira
HOBBY

16 days ago

what is funny that bun almost 3x cost of all my other services compined XD


justkira
HOBBY

16 days ago

I Hope i don't go bankrupt before the fix because im using bun s3 client will be hard for me to remove it now


16 days ago

Ah so you can't just switch back to Node to check if the memory leak is bun specific.


justkira
HOBBY

16 days ago

well its kinda bun spefic i have sveltekit running on node


16 days ago

Though, if it makes the situation better, at least memory leaks aren't Railway specific! 🙂


justkira
HOBBY

16 days ago

also hono node support is wake faced alot of issue


justkira
HOBBY

16 days ago

I’m not 100 % sure, but there was a moment when every JS service suddenly ballooned in memory and then—almost in unison—dropped back down. The spike was only about 10 %, so it was pretty minor, but I figured it might have been triggered by an update on your end. Either way, Railway’s been rock-solid for me—smooth sailing all around.


16 days ago

Memory usage is not dependent on our systems, the memory usage is solely your application's usage.


justkira
HOBBY

16 days ago

maybe rust to but it uses soo little memory i didn't notice


justkira
HOBBY

16 days ago

intresting..


justkira
HOBBY

16 days ago

Anyway, I’ll be off having a long, heartfelt chat with my wallet until Bun sorts out that weird memory issue.


justkira
HOBBY

16 days ago

@Brody sorry to bother but why when i set limit 1gb memory dropped like that

1409178601240396000


16 days ago

Memory dropping after a re-deploy would be completely normal.


High Memory Usage in Node & Bun - Railway Help Station