How can I determine the memory limit of a dyno?

Issue

Your code may run on different dyno types and sizes so you want to dynamically determine the processes's memory limit at runtime.

Resolution

The value of /sys/fs/cgroup/memory/memory.limit_in_bytes will represent the amount of memory available:

$ heroku run 'cat /sys/fs/cgroup/memory/memory.limit_in_bytes' --size standard-1x
536870912

$ heroku run 'cat /sys/fs/cgroup/memory/memory.limit_in_bytes' --size standard-2x
1073741824

$ heroku run 'cat /sys/fs/cgroup/memory/memory.limit_in_bytes' --size performance-m
2684354560

$ heroku run 'cat /sys/fs/cgroup/memory/memory.limit_in_bytes' --size performance-l
15032385536

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support