简体   繁体   中英

Why is flask using all of my memory?

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 :

烧瓶,为什么你没有免费?

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):

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM