[PyKDE] QWorkspace and memory

Brett Morgan brett at pulse.itd.uts.edu.au
Fri Sep 14 05:45:39 BST 2001


I am curious as to what your user interface design is, such that you
are interested in opening and closing hundreds of windows? Even when I
have gone made in netscape, i usually only have like ten of them
open. And that could easily be handled by sticking all the panes
inside a tab control. 

I am not belittling your effort in finding where the memory is
"leaking", even though I suspect you will find the underlying qt
library is using a pooling mechanism due proabably to a high
instantion cost for windows. The usual window creation idioms for
window system usage is to create a main window, and then repeatedly
create and destroy popups and dialogs - there usually be a fairly
consistent upper bound on the number of these windows - thus making a
pooling strategy a useful optimisation in the underlying windowing
toolkit.

On Fri, Sep 14, 2001 at 12:47:25AM +0100, Phil Thompson didst scribe:
> Gey-Hong Gweon wrote:
> > 
> > Dear all,
> > 
> > I am investigating into ways to use memory more efficiently so that my
> > data analysis program does not critically slow down my computer after
> > opening and closing hundreds of windows over time. So far, I have been
> > quitting and restarting my program when the slow-down occurs, but I
> > would feel less itchy if I could do better. I am using QWorkspace in my
> > program, and to get at this memory problem, I wrote the script that I
> > paste at the end of this message. Running this script, you get two
> > buttons -- "New Windows" and "Delete Windows" -- which create and delete
> > , respectively, 50 windows at a time. For deleting the windows, I am
> > just closing the windows which were created with the
> > Qt.WDestructiveClose widget flag. These windows are children of a
> > QWorkspace instance and I monitor how many children are owned by my
> > QWorkspace instance by looking at the .children () method. The number of
> > children increases (decreases) as I create (delete) windows, as
> > expected. However, if I look at the memory usage of this script by using
> > an external program "top", I get the following results.
> > 
> > Action  N_win   PROG SIZE (kbyte)
> > -----------------------
> > Startup 0               7836
> > +50             50              9052
> > +50             100             9844
> > +50             150             10628
> > +50             200             11412
> > -50             150             11420
> > -50             100             11420
> > -50             50              11420
> > -50             0               11420
> > +50             50              11420
> > +50             100             11420
> > +50             150             11420
> > +50             200             11516
> > +50             250             12328
> > +50             300             13104
> > 
> > I.e., the program size seems to only increase and never
> > decrease. However, notice that as N_win reaches to 200 the second time,
> > it uses about the same memory as the first time. Therefore, it looks as
> > though when windows are deleted, the program does not seem to free the
> > memory space for those windows, but does not hold it for nothing either
> > -- the space is eventually re-used if more windows are created. Is this
> > behavior due to Qt or PyQt? Is this the correct behavior or can I make
> > the program size decrease when I delete windows? If so, how?
> > 
> > I am using Linux Mandrake 7.2, python-2.0, and PyQt-2.3.
> 
> Is it possible for you to re-write your test in C++ and see if you get
> the same results?
> 
> Phil
> 
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.gmd.de
> http://mats.gmd.de/mailman/listinfo/pykde

brett

-- 
email: Brett.Morgan at uts.edu.au
phone: 0416-241-898
magic: 153 2 8 105 225

There is a lit brass lamp here.

To a Lisp hacker, XML is S-expressions in drag.




More information about the PyQt mailing list