R14 – Memory Quota Exceeded

We, like many other organisations, are using heroku as the deployment server for our project open event organizer server. Things are pretty simple and awesome when your project is in its beginning phase and things run pretty smoothly. But as your project grows, there comes some server problem. And one of the biggest problems as your project grows is memory. Now since various packages have a different amount of memory assigned to you in case of hosting in generic servers such as heroku, so it might result in memory quota exceeded. Recently, we faced such a problem. R14 – Memory Quota Exceeded. Took us quite some time to understand what and why and how this occurred. So let me share a few things I found about this error.

So what does this error R14 – Memory Quota Exceeded? According to Heroku error definitions,

A dyno requires memory in excess of its quota. If this error occurs, the dyno will page to swap spaceto continue running, which may cause degraded process performance. The R14 error is calculated by total memory swap and rss; cache is not included.

2011-05-03T17:40:10+00:00 app[worker.1]: Working
2011-05-03T17:40:10+00:00 heroku[worker.1]: Process running mem=1028MB(103.3%)
2011-05-03T17:40:11+00:00 heroku[worker.1]: Error R14 (Memory quota exceeded)
2011-05-03T17:41:52+00:00 app[worker.1]: Working

If you are getting a large number of R14 errors, your application performance is likely severely degraded.

Basically, this error occurs due to Memory Leaks. A memory leak is defined as memory increasing indefinitely over time. Most applications that have memory problems are defined as having a “memory leak” however if you let those applications run for a long enough period of time, the memory use will level out. In Heroku, R14 means that the main memory quota is exceeded and it starts using swap memory which is really dangerous and the application would surely crash.

So, this errors occur due to too much usage of memory at run-time. There are many different reasons that can cause this and it varies from language to language, application to application. In Flask, some of the common reasons that may cause this error are:

  • Too many migrations – Sometimes too many migrations may lead to memory quota being exceeded while migrating your database.
  • Too many SQL Queries – If there are too many unnecessary and redundant SQL queries then it might result in the memory quota being exceeded at run-time.

There can be many other reasons. But this is what we faced in our project. Hope this blog helps you to better debug in case of a R14 error in Heroku.

Published by


Full Stack Developer, Open Source enthusiast