470,849 Members | 697 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

tkinter: not freeing memory like I'd expect

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
Mar 30 '06 #1
0 780

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Elbert Lev | last post: by
2 posts views Thread by codecraig | last post: by
5 posts views Thread by disco | last post: by
11 posts views Thread by Rodrigo Dominguez | last post: by
6 posts views Thread by Fernando Cacciola | last post: by
4 posts views Thread by Atul Sureka | last post: by
66 posts views Thread by karthikbalaguru | last post: by
11 posts views Thread by vivek | last post: by
25 posts views Thread by Andreas Eibach | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.