tkinter: not freeing memory like I'd expect

Discussion in 'Python' started by Benjamin Rutt, Mar 30, 2006.

  1. I have a bunch (e.g. 40) of tkinter Text objects in a gui on a linux
    machine, tracking monitoring info per host. They accumulate up to
    500MB of text data (according to /bin/top) over time reading from
    sockets. I want to release this memory first by clearing all the text
    contents, but keeping the Text objects in the GUI, via a callback
    like:

    def erase_all_text():
    for h in known_hosts_texts.keys():
    t = known_hosts_texts[h]
    t.config(state=NORMAL)
    t.delete('1.0',END)
    t.config(state=DISABLED)

    But after calling the function, although the texts are cleared, no
    memory is released according to /bin/top (the process is still 500MB
    large). Next, I try to remove all objects from the GUI, in the hope
    that will free the memory:

    def clear_all():
    global known_hosts
    global known_hosts_frames
    global known_hosts_texts

    known_hosts = {}
    known_hosts_frames = {}
    known_hosts_texts = {}

    for w in frametop.children.values():
    w.destroy()

    Got those last 2 lines from a Fredrik Lundh post I think. But again,
    the process is still 500MB large.

    I should point out that the erase_all_text() and clear_all() do what
    they're told for the GUI, appearance-wise, it's just that I'd expect
    the memory footprint to be reduced when they are called. The lack of
    a reduction eats up my memory space and causes the out-of-memory linux
    killer to fire up eventually. Am I doing anything wrong in either of
    my approaches? Or should I not expect memory to be released?
    --
    Benjamin Rutt
     
    Benjamin Rutt, Mar 30, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rodrigo Dominguez

    memory allocation and freeing memory

    Rodrigo Dominguez, Jun 13, 2005, in forum: C Programming
    Replies:
    11
    Views:
    633
    Jean-Claude Arbaut
    Jun 15, 2005
  2. jithoosin
    Replies:
    0
    Views:
    329
    jithoosin
    Jul 21, 2006
  3. jithoosin
    Replies:
    1
    Views:
    294
    Kai-Uwe Bux
    Jul 21, 2006
  4. Simon Strandgaard

    how to expect eof with expect+pty

    Simon Strandgaard, Dec 20, 2006, in forum: Ruby
    Replies:
    4
    Views:
    391
    Simon Strandgaard
    Dec 20, 2006
  5. Phil
    Replies:
    0
    Views:
    181
Loading...

Share This Page