8

I created the simplest Flask app I could imagine:

import flask
from flask import Flask

application = Flask(__name__)

@application.route('/')
def index():
    return flask.jsonify(ok=True)

I deployed this app on 1/26 to Elastic Beanstalk. It has served 0 requests since deployment. Here is a graph of the memory usage, using Amazon's memory monitoring scripts:

Flask, why you no free?

You can see the little dip where (I assume) garbage collection happened on 1/29. But what on earth is allocating so much memory? If this is normal, how should I be monitoring memory so I can actually figure out if my (real) application has a memory leak? Is this Flask's fault, Python's fault, AWS's fault, ...something else?

Edited to add: I switched over to using mod_wsgi this aftenoon, but it didn't seem to have any effect. Updated graph (the dips are deploying new versions, it took a few tries to get the config right):

Continuing memory issues with WSGI

Output of free -m:

             total       used       free     shared    buffers     cached
Mem:           532        501         31          0         81         37
-/+ buffers/cache:        381        150
Swap:            0          0          0
0

1 Answer 1

5

Is that memory actually being used or is it cached? SSH into your beanstalk instance and use the free command to determine this. This article has a good breakdown of how to determine whether your RAM is actually used or cached and what it means.

Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately, free on Elastic Beanstalk doesn't have the available column! (I'd guess it's too old?) However, it sounds like the buffers/cache line's free column is a reasonable proxy for that, and that's holding steady at ~145MB.
I added the output of free to the bottom my question.
Cool, so yes, the line that says -/+ buffers/cache shows the actual memory being used. The rest is being held in cache and will be released by the OS as required for other programs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.