Service behaving differently from when it is run on my machine

cicerorphHOBBY

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.

Solved$10 Bounty

7 Replies

cicerorphHOBBY

3 days ago

6d6ce155-f2d5-44d5-97fd-1fb27ad54557


idiegea21HOBBY

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.

cicerorphHOBBY

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


cicerorphHOBBY

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

Jun 10 09:09:49

Heap used: 86.07 MB

Jun 10 09:09:50

Heap used: 86.07 MB

Jun 10 09:09:51

Heap used: 86.07 MB

Jun 10 09:09:52

Heap used: 86.13 MB

Jun 10 09:09:52

<-- GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392&timestamp=1749557392

Jun 10 09:09:53

Heap used: 100.66 MB

Jun 10 09:09:54

Heap used: 102.12 MB

Jun 10 09:09:54

Request lenta: /img/rank - 2078ms

Jun 10 09:09:54

--> GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392&timestamp=1749557392 200 2s

Jun 10 09:09:55

<-- GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392&timestamp=1749557392

Jun 10 09:09:55

Heap used: 120.55 MB

Jun 10 09:09:56

Request lenta: /img/rank - 1198ms

Jun 10 09:09:56

--> GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392&timestamp=1749557392 200 1s

Jun 10 09:09:56

Heap used: 124.24 MB

Jun 10 09:09:57

Heap used: 124.24 MB

Jun 10 09:09:58

<-- GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392&timestamp=1749557392

Jun 10 09:09:58

Heap used: 141.88 MB

Jun 10 09:09:59

Request lenta: /img/rank - 1203ms

Jun 10 09:09:59

--> GET /img/rank?data=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654,1270551876705714262:5000654,1267984282203328515:3752773&extraData=759806779516780574:14478581,1215749332809154643:10009132,1128442742679281706:5000654&r=1749557392&timestamp=1749557392 200 1s

Jun 10 09:09:59

Heap used: 144.74 MB

Jun 10 09:10:00

Heap used: 144.74 MB

Jun 10 09:10:01

Heap used: 144.74 MB

Jun 10 09:10:02

Heap used: 144.80 MB

Jun 10 09:10:03

Heap used: 144.80 MB

Jun 10 09:10:04

Heap used: 144.80 MB

Jun 10 09:10:05

Heap used: 144.80 MB

Jun 10 09:10:06

Heap used: 144.83 MB

Jun 10 09:10:07

Heap used: 144.83 MB

Jun 10 09:10:08

Heap used: 144.83 MB

Jun 10 09:10:09

Heap used: 144.83 MB

Jun 10 09:10:10

Heap used: 144.83 MB

Jun 10 09:10:11

Heap used: 144.83 MB

Jun 10 09:10:12

Heap used: 144.83 MB

Jun 10 09:10:13

Heap used: 85.96 MB

Jun 10 09:10:14

Heap used: 85.96 MB

Jun 10 09:10:15

Heap used: 85.96 MB

Jun 10 09:10:16

Heap used: 85.96 MB
```


cicerorphHOBBY

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.


cicerorphHOBBY

3 days ago

Also, heap for some reason isn't the actual memory being used in railway so I don't know


cicerorphHOBBY

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.


cicerorphHOBBY

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


Service behaving differently from when it is run on my machine - Railway Help Station