Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68359

Re: script uses up all memory

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'causing': 0.04; 'debug': 0.07; 'executed': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'django': 0.11; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'url:djangoproject': 0.16; 'url:faq': 0.16; 'prevent': 0.16; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'url:dev': 0.24; 'query': 0.26; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'mode': 0.30; 'away.': 0.31; 'larry': 0.31; 'writes:': 0.31; 'this.': 0.32; 'figure': 0.32; 'subject:all': 0.32; 'saves': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'skip:t 30': 0.61; 'from:charset:utf-8': 0.61; 'received:130': 0.73; 'kent': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From kent@lysator.liu.se (Kent Engström)
Subject Re: script uses up all memory
Date Fri, 14 Mar 2014 15:10:07 +0100
References <CACwCsY65gpn_Zx78wquE-rmrZu10pu9GYbzWd-Y3ypzHsMb2Yw@mail.gmail.com> <CACwCsY4nxs-4WmKboA9mOwrjQjXKXmaBPTuuq0GSmjzEpA3efQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host c-76-112.eduroam.liu.se
User-Agent Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)
Cancel-Lock sha1:Q3KmG4v5+FbHTdBVkZSUPIWtn1o=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8151.1394806137.18130.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1394806137 news.xs4all.nl 2890 [2001:888:2000:d::a6]:34478
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68359

Show key headers only | View raw


Larry Martell <larry.martell@gmail.com> writes:
> I figured out what is causing this. Each pass through the loop it does:
>
> self.tools = Tool.objects.filter(ip__isnull=False)
>
> And that is what is causing the memory consumption. If I move that
> outside the loop and just do that once the memory issue goes away. Now
> I need to figure out why this is happening and how to prevent it as
> they do want to query the db each pass through the loop in case it has
> been updated.

Django saves a copy of every executed SQL query if it is in debug mode
(if the DEBUG setting is true). See

https://docs.djangoproject.com/en/dev/faq/models/#why-is-django-leaking-memory

Regards,
/ Kent Engström, Lysator

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: script uses up all memory kent@lysator.liu.se (Kent Engström) - 2014-03-14 15:10 +0100

csiph-web