为什么烧瓶会占用我的所有内存? [英] Why is flask using all of my memory?

查看:90
本文介绍了为什么烧瓶会占用我的所有内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了我能想到的最简单的Flask应用程序:

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)

我在1/26上将此应用程序部署到Elastic Beanstalk.自部署以来,该服务已处理0个请求.这是使用 Amazon的内存监视脚本的内存使用图:

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:

您可以看到在1/29处发生(我假设)垃圾收集的小幅度下降.但是到底分配了多少内存呢?如果正常,我应该如何监视内存,以便实际上可以确定我的(实际)应用程序是否存在内存泄漏?这是Flask的错,Python的错,AWS的错,...其他吗?

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?

编辑后添加:在此之后,我改用了mod_wsgi,但似乎没有任何效果.更新了图表(Dip正在部署新版本,花了一些尝试才能正确配置):

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

free -m的输出:

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

推荐答案

该内存是实际使用的还是已缓存?通过SSH进入beantalk实例,并使用free命令确定这一点. 这篇文章详细介绍了如何确定您的RAM是实际使用还是缓存以及它的含义.

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.

这篇关于为什么烧瓶会占用我的所有内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆