8 months ago
Hello!
I recently added uploadthing library to my project to let people handle photo uploads. It cause an immediate memory usage spike from 150-170mb to around 500mb, then I made a code cleanup, removed unnecessary components and files and rebuilt the app - the memory usage spiked to almost 1.5 gigs, and settled at around 1gb for now. It's huge and seems a bit unrealistic for such a simple thing. It doesn't seem right that it would cause an additional gigabyte of constant usage.
There's a high chance I did something wrong too, but I decided to seek help from professionals.
At this point I have no idea what exactly has happened but I was wondering if you can help me check what exactly is causing the issue. Might be there's a memory leak or anything else, but the metrics do not give me any useful info.
4 Replies
8 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 8 months ago
8 months ago
Hello again - I've been looking for a long time but I am unable to diagnose the issue. I switched from uploadthing to using a regular CDN with only a server action that handles posting and deleting photos via simple fetch, yet the app usage is still way higher than it was before. It jumped from 150-170mb to 500, and now it is showing 700ish mb of usage. Nothing has really changed in the app, there's no caching, and this usage seems like it came out of nowhere. I tried doing some diagnostics and didn't find any memory leaks but my ability to diagnose such things and their understanding is limited.
here:s the project ID: 63cbc7dd-463b-4a54-a8e6-4b2bc3ea8cd4
How can I proceed to find the culprit?
8 months ago
Hello, unfortunately Railway does not have any more observability into what your code is doing than you would, we are simply running it as-is and reporting the usage it uses.
But from experience with how you described this issue, it sounds like you are buffering the entire file into memory instead of streaming the upload.
8 months ago
I removed the library and the usage fixed itself for a while but then I can see that right now it' showing 2.5 gigs of ram usage once again. It seems kind of absurd, could it be gc? I really do not know what to do at this point
8 months ago
I'm really sorry but we are not able to provide coding support as this is an application level issue.