Theo's Typesafe CultTTC
Theo's Typesafe Cult17mo ago
6 replies
Toothy

Huge memory usage spikes with uploadthing, seeking help on how to handle it.

Hey folks!

I've just added uploadthing to my project that's currently being used by a small company. We agreed to use uploadthing for very simple photo management where you can add a picture and then set a URL in a database, to later display it.

My base memory usage for the app was around 15- to 170mb, it spiked to 500mb for the night where the app is completely inactive, then it spiked to around 1 GB of constant usage. The peak was at 2GB. The photos are 10MB total so it's really not much.

I host on railway and it doesn't really allow me precisely what's using the memory, but it started right after adding uploadthing. I am really not sure what could be causing that - I was thinking it's UTapi on the server.

Is it common with uploadthing to have such a huge memory consumption? Should I be doing something specific to manage it? If not, do you folks have any suggestions that could at least guide me on a correct path?

I am sorry if I haven't provided enough information, please do let me know what I should update.

About the app: It's a CRM / Order management system that's being used by 10ish people. Everything's in NextJS, using server actions, hosted on railway hobby plan.

small edit: I tried reddit, also some suggestions from friends (garbage collection, memory leaks) but I don't really know what I can do with them. Also tried googling for the answer but there seems to not be that many resources about uploadthing.

edit 2: adding things that come to my mind. I only use uploadthing for simple small image uploads, then utapi.deleteFiles to delete stored files - nothing complicated.
image.png
Was this page helpful?