【问题标题】:Boto SQS get_queue Memory LeakBoto SQS get_queue 内存泄漏
【发布时间】: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


    【解决方案1】:

    只需从 INSTALLED_APPS 中删除 debug_toolbar...

    【讨论】:

    • 我在 INSTALLED_APPS 中没有 debug_toolbar,但内存泄漏仍在发生。你还有什么建议吗?
    • 这就像 7 年前一样。我认为您的 memleak 可能与这个问题无关。对于使用 Django 的我来说,导致内存泄漏的通常是调试和分析工具。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-08
    • 2013-01-20
    • 2011-10-31
    • 2019-08-10
    • 2013-06-24
    • 2011-03-22
    • 2015-04-20
    相关资源
    最近更新 更多