[PyKDE] QWorkspace and memory

Phil Thompson phil at river-bank.demon.co.uk
Fri Sep 14 01:46:24 BST 2001


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




More information about the PyQt mailing list