React router + Vite memory leak (weird RAM accumulation)

djulian
PRO

23 days ago

Hi,

I have a simple React router + Vite project. The service accumulates RAM overtime to the point where it goes from 200mb (baseline) to about 1GB in about 15 days. (see screenshot attached)

I need to restart the service for it to go back to baseline.

I have this problem with basically every React Router + Vite website I have and a couple of NextJS project as well.

Any idea why ? It's really tedious to redeploy server every time and it ends up costing 5x the actual needs.

Here is the package.json of this specific one:

```
"dependencies": {

"@react-router/node": "^7.5.3",

"@react-router/serve": "^7.5.3",

"@tanstack/react-query": "^5.81.2",

"@uidotdev/usehooks": "^2.4.1",

"axios": "^1.10.0",

"dayjs": "^1.11.13",

"gray-matter": "^4.0.3",

"isbot": "^5.1.27",

"lucide-react": "^0.522.0",

"mapbox-gl": "^3.13.0",

"marked": "^15.0.12",

"posthog-js": "^1.255.1",

"qrcode.react": "^4.2.0",

"react": "^19.1.0",

"react-dom": "^19.1.0",

"react-map-gl": "^8.0.4",

"react-router": "^7.5.3",

"react-router-hono-server": "^2.13.0",

"slugify": "^1.6.6",

"tailwind": "^4.0.0",

"zustand": "^5.0.5"

}
```

Attachments

$10 Bounty

2 Replies

Railway
BOT

23 days ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


fra
HOBBYTop 5% Contributor

21 days ago

I don't think there is a magic recipe to find memory leak, the best thing would be to debug taking snapshot of the memory and look if there are weird thing in the snapshot...

  • do you have any kind of cache that might add stuff without removing expired stuff?

  • check if you are creating new instances of any clients instead of reusing


React router + Vite memory leak (weird RAM accumulation) - Railway Help Station