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


Groups > comp.lang.python > #77695

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!news.unit0.net!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed3a.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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'causing': 0.04; 'received:198': 0.07; '[0]': 0.09; '__init__': 0.09; 'advice.': 0.09; 'expected.': 0.09; 'url:github': 0.09; 'python': 0.11; 'itself.': 0.14; 'bug,': 0.16; 'commented': 0.16; 'filename:fname piece:signature': 0.16; 'improper': 0.16; 'manifests': 0.16; 'programmer,': 0.16; 'subject:slow': 0.16; 'url:explore': 0.16; 'url:py': 0.16; 'folks': 0.16; 'wrote:': 0.18; 'code.': 0.18; "python's": 0.19; 'received:10.0.1': 0.19; 'unlike': 0.19; 'fit': 0.20; 'example': 0.22; 'header:In-Reply- To:1': 0.27; 'appear': 0.29; 'michael': 0.29; 'absolute': 0.30; 'kevin': 0.30; 'code': 0.31; 'lines': 0.31; 'that.': 0.31; 'languages:': 0.31; 'skip:q 20': 0.31; 'class': 0.32; 'minimal': 0.33; 'could': 0.34; 'problem': 0.35; 'something': 0.35; 'objects': 0.35; 'c++': 0.36; 'doubt': 0.36; 'thanks': 0.36; "i'll": 0.36; 'received:10.0': 0.36; 'so,': 0.37; 'list': 0.37; 'received:10': 0.37; 'button': 0.38; 'problems': 0.38; 'stopped': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'mailing': 0.39; 'most': 0.60; 'save': 0.62; 'kind': 0.63; 'between': 0.67; 'grow': 0.77; 'itself?': 0.84; 'leak.': 0.84; 'much,': 0.84; 'url:master': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1410122384; bh=gOsmMW8jHZTAetTLQM6jpPSkB6hY47hLiZfxMemxZog=; h=Date:From:To:Subject:References:In-Reply-To:From; b=jLaocchJCUgsdGwa2kf4K721BVNktKISRDY0nYaVeSfmhSSbwvZs5Bjyn+M0nld1n IEFihor4KEpt8zuiO5AUDmvnpv6NicB6IHIcasPAm+NrFpKpe1viT4zhAM2bZyUMKD BFzio2bDPZGcV3e6E24BfKOyuPWgGu2ohmtdPM2k=
Date Sun, 07 Sep 2014 20:39:20 +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> <540CADDD.3050501@riseup.net> <540CB15C.2060008@gmail.com>
In-Reply-To <540CB15C.2060008@gmail.com>
Content-Type multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="j3evN5BLmXqMDB6MLBcSiK5ddmJHhFivo"
X-Virus-Scanned clamav-milter 0.98.4 at mx1
X-Virus-Status Clean
X-Mailman-Approved-At Mon, 08 Sep 2014 09:05:24 +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.13862.1410159925.18130.python-list@python.org> (permalink)
Lines 270
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1410159925 news.xs4all.nl 2872 [2001:888:2000:d::a6]:39682
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77695

Show key headers only | View raw


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

Michael Torrie:
> On 09/07/2014 01:11 PM, kjs wrote:
>> 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.
> 
> Can you make an absolute minimal example with no widgets save the graph
> itself?  You could then go to the PyQt folks with that.  Could be a bug,
> or could be an improper use of something by your code.  This is one of
> the problems with using Qt in other languages: it's not a perfect fit
> for Python's object model as it is C++-based.  So you have to think like
> a C++ programmer, and you might have to manage some resources manually,
> unlike normal Python objects which for the most part take care of
> themselves.
> 

The code is minimal[0]. The only other widgets are a start button that
fires off the plotting and a stop button that calls sys.exit().

Lines 112-114 appear to be causing the weakref proliferation.

I do not doubt that I could be using PyQt4 incorrectly. I'll send a
message to the pyqt mailing list as well.

> Also you could try a minimal example using PySide instead of PyQt and
> see if that also manifests the leak.  If so, then the problem could be
> in Qt itself.  Though I suspect the problem is some kind of impedance
> mismatch between C++ and Python.
> 

Thanks much,
Kevin

[0]
https://github.com/kevinjos/kaggle-aes-seizure-prediction/blob/master/explore.py

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 20:39 +0000

csiph-web