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.
4 Replies
somehow I just can't find the source of the problem
tracing + diagnostics
Node.js — Memory
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
My solution was to ditch uploadthing and use bunny.cdn for photos - somehow uploadthing just took itself 1.5GB of constant memory usage and after removing it everything went back to normal. There was no caching or anything like that, and it was using 1.5GB while dealing with total of 10mb of photos.
i did some diagnostics there did not seem to be any memory leaks or anything like that