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


Groups > comp.lang.python > #77683

Re: weakref, memory management and execution slow down in PyQt4

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!195.208.113.2.MISMATCH!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <bfb@riseup.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'causing': 0.04; 'received:198': 0.07; 'tool,': 0.07; '__init__': 0.09; 'advice.': 0.09; 'expected.': 0.09; 'python': 0.11; 'gui': 0.12; 'suggest': 0.14; 'antoine': 0.16; 'attributed': 0.16; 'commented': 0.16; 'filename:fname piece:signature': 0.16; 'finer': 0.16; 'stable.': 0.16; 'subject:slow': 0.16; "python's": 0.19; 'received:10.0.1': 0.19; '>>>': 0.22; 'memory': 0.22; 'separate': 0.22; 'replace': 0.24; 'visible': 0.24; 'regardless': 0.24; 'header:In-Reply-To:1': 0.27; 'consumption': 0.31; 'further?': 0.31; 'skip:q 20': 0.31; 'writes:': 0.31; 'class': 0.32; 'url:python': 0.33; 'older': 0.33; 'core': 0.34; 'objects': 0.35; 'but': 0.35; 'there': 0.35; 'next': 0.36; 'thanks': 0.36; 'received:10.0': 0.36; 'url:org': 0.36; 'application': 0.37; 'received:10': 0.37; 'growing': 0.38; 'stopped': 0.38; 'tools,': 0.38; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'remove': 0.60; 'analysis,': 0.60; 'analyze': 0.60; 'url:3': 0.61; 'first': 0.61; 'such': 0.63; 'believe': 0.68; 'analysis': 0.75; 'grow': 0.77; '3.4': 0.84; 'antoine.': 0.84; 'execution.': 0.84; 'isolate': 0.84; 'factors': 0.97
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1410117103; bh=3FueyHINtsUAD8LiStc4BZwkVxAg2mx5m7YSY4w125k=; h=Date:From:To:Subject:References:In-Reply-To:From; b=NbPsZ4l4g0udIhFpR+T0XM0EtBKC3D1Ye+8s5b35ndgcCK3l4sHWWTop45HegijJd RTtt9ekxusB6BXZHGAxXgDfY6o7guTrTfYTL88qccQLotzV7c10pxDLZptTdw1U084 F2tPBhUNIvZlKUrmXtXqwPkFWmKO+r+UWY95RPwA=
Date Sun, 07 Sep 2014 19:11:25 +0000
From kjs <bfb@riseup.net>
MIME-Version 1.0
To python-list@python.org
Subject Re: weakref, memory management and execution slow down in PyQt4
References <540BFE43.5030006@riseup.net> <loom.20140907T152314-538@post.gmane.org>
In-Reply-To <loom.20140907T152314-538@post.gmane.org>
Content-Type multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="OOHpPFpnaRCJ8F8ArdXeBakgXsHTO4xCL"
X-Virus-Scanned clamav-milter 0.98.4 at mx1
X-Virus-Status Clean
X-Mailman-Approved-At Sun, 07 Sep 2014 21:14:14 +0200
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.13851.1410117255.18130.python-list@python.org> (permalink)
Lines 275
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1410117255 news.xs4all.nl 2892 [2001:888:2000:d::a6]:50949
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77683

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Antoine Pitrou:
> kjs <bfb <at> riseup.net> writes:
>>
>> I have come to believe that the growing number of weakrefs is slowing
>> down execution. Is my analysis misguided? How can I introspect further?
>> If the slowdown can be attributed to weakref escalation, what are some
>> next steps?
> 
> The way to analyze this is to build some gradually smaller subsets of your
> application until you can isolate what is causing the growth in number of
> objects (if any). I would suggest first remove the GUI and replace it with
> some dummy functions, to stress your core logic.

Thanks for the advice. I commented out the graph generation and PyQt call

>>> self.app.processEvents()

where in the class __init__

>>> self.app = QtGui.QApplication(sys.argv)

This stopped the weakref proliferation. All other objects grow and
shrink in number as expected.

> 
> Note that "top" isn't a very reliable tool, as memory fragmentation and
> other factors can cause your process' visible size to grow even though
> Python's memory consumption may be stable. There are dedicated Python tools
> for finer analysis, such as tracemalloc, which is standard on 3.4 and available
> as a backport for older versions:
> 
> https://docs.python.org/3/library/tracemalloc.html
> http://pytracemalloc.readthedocs.org/
> 
> But regardless of such tools, the approach above (try to decompose your
> workload into separate parts until your find the culprit) is highly recommended.
> 
> Regards
> 
> Antoine.
> 
> 

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


Thread

Re: weakref, memory management and execution slow down in PyQt4 kjs <bfb@riseup.net> - 2014-09-07 19:11 +0000

csiph-web