Tkinter uses a lot of memory?!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ServantOfTheSecretFire

    Tkinter uses a lot of memory?!

    Hi there,

    I wrote my first Python program this weekend, Conway's Game of Life,
    and I used Tkinter for the graphics. I thought I had done something
    wrong when I saw the memory consumption, so I wrote the simplest Tk
    program I could, and yep, it takes about 40MB of memory! I'm using Red
    Hat Linux 9.0 and recent versions of the software. Please look at the
    output below, and tell me if I am confused...

    ~/python: cat /etc/redhat-release
    Red Hat Linux release 9 (Shrike)

    ~/python: rpmquery python
    python-2.2.2-26

    ~/python: rpmquery tk
    tk-8.3.5-88

    ~/python: rpmquery tkinter
    tkinter-2.2.2-26

    ~/python: cat hello.py
    #!/usr/bin/python
    import Tkinter as Tk
    root = Tk.Tk()
    Tk.Button(text= 'Quit', command=root.qu it).pack()
    root.mainloop()

    ~/python: python hello.py &
    [1] 25633

    ~/python: ps u
    USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
    sjm 23897 0.0 0.2 4980 1088 pts/0 S 12:18 0:00 -csh
    sjm 25633 4.8 7.2 41576 37352 pts/0 S 22:35 0:00 python
    hello.py
    sjm 25634 0.0 0.1 2616 660 pts/0 R 22:35 0:00 ps u
  • Ivan Voras

    #2
    Re: Tkinter uses a lot of memory?!

    ServantOfTheSec retFire wrote:
    [color=blue]
    > wrong when I saw the memory consumption, so I wrote the simplest Tk
    > program I could, and yep, it takes about 40MB of memory! I'm using Red
    > Hat Linux 9.0 and recent versions of the software. Please look at the
    > output below, and tell me if I am confused...[/color]
    [color=blue]
    > sjm 25633 4.8 7.2 41576 37352 pts/0 S 22:35 0:00 python[/color]


    Can't say about linux, but on windows your program takes about 5.5MB.

    --
    --
    Every sufficiently advanced magic is indistinguishab le from technology
    - Arthur C Anticlarke


    Comment

    • Paul Clinch

      #3
      Re: Tkinter uses a lot of memory?!

      servantofthesec retfire@fea.st (ServantOfTheSe cretFire) wrote in message news:<f2adc03e. 0311162026.3c28 2ccf@posting.go ogle.com>...[color=blue]
      > Hi there,
      >
      > I wrote my first Python program this weekend, Conway's Game of Life,
      > and I used Tkinter for the graphics. I thought I had done something
      > wrong when I saw the memory consumption, so I wrote the simplest Tk
      > program I could, and yep, it takes about 40MB of memory! I'm using Red
      > Hat Linux 9.0 and recent versions of the software. Please look at the
      > output below, and tell me if I am confused...[/color]

      Wow!
      [color=blue]
      > ~/python: cat /etc/redhat-release
      > Red Hat Linux release 9 (Shrike)
      >[/color]
      Suse 8.2
      [color=blue]
      > ~/python: rpmquery python
      > python-2.2.2-26
      >[/color]
      rpm -qf $(which python)
      python-2.2.2-82
      [color=blue]
      > ~/python: rpmquery tk
      > tk-8.3.5-88
      >[/color]
      rpm -q tk
      tk-8.4.2-27
      [color=blue]
      > ~/python: rpmquery tkinter
      > tkinter-2.2.2-26
      >[/color]
      rpm -q python-tk
      python-tk-2.2.2-92
      [color=blue]
      > ~/python: cat hello.py
      > #!/usr/bin/python
      > import Tkinter as Tk
      > root = Tk.Tk()
      > Tk.Button(text= 'Quit', command=root.qu it).pack()
      > root.mainloop()
      >
      > ~/python: python hello.py &
      > [1] 25633
      >
      > ~/python: ps u
      > USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
      > sjm 23897 0.0 0.2 4980 1088 pts/0 S 12:18 0:00 -csh
      > sjm 25633 4.8 7.2 41576 37352 pts/0 S 22:35 0:00 python
      > hello.py[/color]

      pac 2947 1.6 2.1 11216 5556 pts/1 S 21:24 0:00 python
      [color=blue]
      > sjm 25634 0.0 0.1 2616 660 pts/0 R 22:35 0:00 ps u[/color]

      I suppose all can suggest is that you do a lsof | grep sjm and spent
      some time working out what shared libraries have been pulled in.

      Regards, Paul Clinch

      Comment

      Working...