Hi! I deployed my ‘ddr-store’ app using Render about 6 months ago using the Starter package, and the app has run fine until about a week ago. All of the sudden, I started getting the error
Ran out of memory (used over 512MB) while running your code.
I double-checked, and I hadn’t made any changes to my app since April 2023. It ran fine up until last week.
So, what could have changed to cause this error?
As a side note, how do I check the total deployed size of the repository?
It’s a bit difficult to say exactly why your app is OOMkilling, but I do see that the server was unhealthy and restarted on August 14, and started OOMkilling after that restart. It’s possible that after the initial restart, something started running differently.
I do see some warnings in your logs that you may want to address such as the warning around caniuse-lite being outdated. I would recommend triggering a new deploy to update this and other dependencies within you app. Your most recent deploy looks to be failing since your index.js references a file ./reportWebVitals, which is not being found. You may need to remove this reference for the deploy to succeed.
I would also recommend ensuring that you are using the same version of Node that you are using locally. Currently it’s defaulting to an older version 14.17.0. This can be updated using the following methods: https://render.com/docs/node-version.
To answer your other question, you can use du -sh <filepath> to check the size of a directory. However, it looks like the error you’re seeing is related to memory usage which is not necessarily correlated with the size of your repo.
As a side note, the build process launches successfully, but I see this message during the build process:
Aug 26 07:15:27 PM ==> Cloning from https://github.com/robliou/... Aug 26 07:15:29 PM ==> Checking out commit cbdb96ae8451b513feb4bdff26955bd2f1b79b18 in branch main Aug 26 07:15:32 PM ==> Downloading cache... Aug 26 07:16:20 PM ==> Transferred 744MB in 15s. Extraction took 28s.
Given that starter packages are limited to 512MB, does this mean I need to get my package size below this amount? If so, why didn’t I face this issue earlier?
It looks like there’s something happening during the startup that’s causing the application to use more memory, so you might need to invesigate that further.
I see in the logs Starting the development server… during startup. If your application is using a development server, that could be causing some issues since there may be additional processes as opposed to a production version of the app. Since you are using create react app, have you considered deploying it as a static site instead, or is there any reason you require using a web service?
The size of the cache/repo is not necessarily correlated to the memory usage, so I don’t think you would need to worry about the Transferred 744MB in 15s. log line in this case.
Thanks for continuing to look into this with me. I went ahead and switched to an ‘optimized production build’ (via react-app-rewired build), but am still getting the memory error?
I think because I’m using react-app-rewired, this forces me to launch this as a web service instead of a static site. For the record, I’ve tried launching this using a static site, but it’s never succeeded…
I was doing some testing and was able to get it working as a Static Site. Since you have a yarn.lock file in your repo but are using npm install, you will need to skip our automatic dependency installation as we are detecting the yarn.lock and trying to install with yarn.
To do this, set an environment variable SKIP_INSTALL_DEPS with the value true in the environment variable tab of the service.
You can keep your build command as-is
Set the publish directory to build
Set a rewrite rule under the redirects/rewrites tab with the source /* and destination /index.html
Let me know if this works for your intended case - otherwise, if you choose to keep this as a web service, I’m not sure that there’s anything else you can do to prevent the spike in memory after the application startup.