Rober Rober - 11 months ago 110
Node.js Question

Limit memory on Heroku Scheduler

I have a few scheduled tasks on Heroku Scheduler addon and I'm hitting the memory limit on a few of them. According to Heroku docs, this is because NodeJs lazy behaviour. I need to explicitly define the memory allocated for the process (512Mb) but not sure how to do it from the Scheduler interface.

This is how it looks when I run it locally:

node --optimize_for_size --max_old_space_size=512 myTask.js

Any idea about passing these values to the Scheduler or a workaround?

Answer Source

I am sure you can pass the extra args to Heroku Scheduler task.

The scheduler uses the same one-off dynos that heroku run uses to execute your jobs, so you can be assured that if it works with heroku run, it will work from the scheduler.

So basically you should be able to test out the command before with heroku run node --optimize_for_size --max_old_space_size=512 myTask.js. The 512MB limit isn't hard limit, so it's not a problem if it shortly reaces the ~530MB limit.