3 days ago
For some reason my RAM is getting bigger and bigger over the time, but when it is running on my computer, it gets a little bigger (40MB) then drops to the normal (80MB)
I'm using Hono, TypeScript and Bun for the service.
7 Replies
3 days ago
Can you share a code snippet of how you're handling requests especially if you're using any global variables, caches, or long-lived objects like Maps or Sets? Also, are you using any third-party libraries or middlewares in Hono? This will help me pinpoint if there's something that might be causing memory to accumulate over time.
idiegea21
Can you share a code snippet of how you're handling requests especially if you're using any global variables, caches, or long-lived objects like Maps or Sets? Also, are you using any third-party libraries or middlewares in Hono? This will help me pinpoint if there's something that might be causing memory to accumulate over time.
3 days ago
I use Redis for cache and the API uses discord.js with voice, and also generates images for the use in another bot.
It gets pfps and others loading them and then putting them into redis for cache
I can't properly give a code snippet, since it's big
3 days ago
And no, I'm not using any third-part middleware, I only have my auth middleware
My only clue its getting bigger every image request.
And I'm logging memory heap, and its going back to 80MB after some seconds:
Logs:
```
Heap used: 86.07 MB
Heap used: 86.07 MB
Heap used: 86.07 MB
Heap used: 86.07 MB
Heap used: 86.13 MB
<-- GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392×tamp=1749557392
Heap used: 100.66 MB
Heap used: 102.12 MB
Request lenta: /img/rank - 2078ms
--> GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392×tamp=1749557392 200 2s
<-- GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392×tamp=1749557392
Heap used: 120.55 MB
Request lenta: /img/rank - 1198ms
--> GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392×tamp=1749557392 200 1s
Heap used: 124.24 MB
Heap used: 124.24 MB
<-- GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392×tamp=1749557392
Heap used: 141.88 MB
Request lenta: /img/rank - 1203ms
--> GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392×tamp=1749557392 200 1s
Heap used: 144.74 MB
Heap used: 144.74 MB
Heap used: 144.74 MB
Heap used: 144.80 MB
Heap used: 144.80 MB
Heap used: 144.80 MB
Heap used: 144.80 MB
Heap used: 144.83 MB
Heap used: 144.83 MB
Heap used: 144.83 MB
Heap used: 144.83 MB
Heap used: 144.83 MB
Heap used: 144.83 MB
Heap used: 144.83 MB
Heap used: 85.96 MB
Heap used: 85.96 MB
Heap used: 85.96 MB
Heap used: 85.96 MB
```
3 days ago
It may be a problem either with my image generation library or hono, as before I changed the image generation library to @napi-rs/canvas it wasn't like this, and also before I changed to hono too.
3 days ago
Also, heap for some reason isn't the actual memory being used in railway so I don't know
3 days ago
Just tested it out, it's really the image routes, I'm going to change the image manipulation library i use to node-canvas and test.
2 days ago
It was the library, @napi-rs/canvas was leaking memory, probably going to report this later, and also try to contact railway support to see if I can get a charge back on the memory leak, if possible.
Status changed to Open sarahkb125 • 1 day ago
Status changed to Solved sarahkb125 • 1 day ago