【发布时间】:2013-11-21 18:59:46
【问题描述】:
我使用 boto.sqs 模块作为 Amazon SQS(简单队列服务)之上的抽象。 一段时间后,我注意到 boto.sqs.get_queue() 会导致持续的内存泄漏。
出于测试目的,我创建了简单的 django 管理命令:
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "My shiny new management command."
def handle(self, *args, **options):
import boto.sqs, time, gc
while True:
conn = boto.sqs.connect_to_region('eu-west-1', aws_access_key_id='my', aws_secret_access_key='my')
queue = conn.get_queue('my')
print('queue is {}'.format(queue))
time.sleep(1)
gc.collect() # just in case
当我执行这个命令时,进程消耗的内存不断增加。 有趣的是,当从简单的 test.py 文件作为“python test.py”执行相同的循环时,它不会发生内存泄漏。
我的 Django 设置中有一行 DEBUG = False。
谁能建议如何摆脱这个 memleak?
【问题讨论】:
标签: python django memory-leaks boto amazon-sqs