Heroku memory spike on file upload

System Information
  • Strapi v4.1.11:
  • Postgresql:
  • Node v14:
  • Yarn 1.22.18:

I am running a hobby dyno on Heroku to host my strapi server to serve media files for my portfolio site and using the AWS provider to upload the files. After every file upload, my dyno memory spikes and does not go back down.

After some looking it seems like this is the issue but I was under the impression this bug was fixed? My server crashes after memory usage sits at 135%. This whole experience doesn’t make sense to me. I am not uploading that many files nor are they large in size.

I would always suggest to upload to buckets or things like Cloudinary etc.
You will get memory spikes as strapi processes etc the data.
If you use a upload provider it will give that data to the provider and rather store it other places.

Sorry, if it wasn’t clear the files are going to an S3 Bucket.

Hi @jaredriver I know it’s been a while since you posted this. Is this something you still experience?

Hi @Richard_Nsama — Unfortunately I couldn’t solve the problem and ended up switching my CMS as I needed a fast solution… I don’t have an update to give.

Sure, thanks for letting me know. We’ve seen an uptick in reports about this and I was hoping to gather as much information as possible to hand off to our Engineers. Yours was on of the first reports about this occurring with Strapi v4.

Hey Richard, I am on v4 and observing the same issue with a Strapi + Heroku + S3 stack. Memory leaking and crashing my Strapi instance as I upload media.

We are on Strapi v4.3.8.

Here is the upload provider plugin we are using:

Hey Richard,

I’m facing a similar problem on my end. My app is running on Render.com, Strapi v4.4.5 and S3 using the official provider @strapi/provider-upload-aws-s3 - npm.

I am using their Starter plan which works fine most of the time, except when I’m trying to upload an image. I don’t understand why uploading a 1MB would cause such a spike in memory, does that have something to do with processing? For now, I had to update to the next larger plan which is ~3-4 times more expensive due to this issue…

Is there maybe a way to instruct Strapi on how much memory is available and cap it at that?

BTW, I didn’t update to the latest Strapi v4.5.4 yet as that gives me another bug, my collections wouldn’t load in the admin area / Content Manager. I haven’t looked into that one yet as there was no hard need for me to upgrade until now.