[ python-Bugs-1342811 ] Tkinter.Menu.delete doesn't delete command of entry

2005-10-30 Thread SourceForge.net
Bugs item #1342811, was opened at 2005-10-30 22:49
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1342811&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Tkinter
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Sverker Nilsson (svenil)
Assigned to: Martin v. Löwis (loewis)
Summary: Tkinter.Menu.delete doesn't delete command of entry

Initial Comment:
Tkinter.Menu.delete does not delete the commands
defined for the entries it deletes. Those objects
will be retained until the menu itself is deleted.

For example, after code like this:

button = Menubutton(root, text='Window')
menu = Menu(button)
button['menu'] = menu
def command():
print 'command button pressed'
menu.add_command(command=command)
menu.delete(END)
del command


the command function will still be referenced and
kept in memory - until the menu object itself is
destroyed.

This may not always be a serious problem, but in
my case the menu was a 'Window' menu and the
command was a method on a window top level widget,
so retaining a pointer to it after deleting the
menu entry kept a reference to that entire window,
with any associated data.

I have figured out a possible fix that is in the
attached file test_menuleak.py that contains some
test functions.

I also changed the comment - for as far as I can
see, the second optional index is actually
INCLUDED in the range of entries deleted.

Version info

Python 2.3.3 (#2, Mar 11 2004, 19:45:43) 
[GCC 2.95.2 2220 (Debian GNU/Linux)] on linux2

I think it applies to all versions: I tested with
the latest 2.4.2 as well.


Sverker Nilsson


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1342811&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1338264 ] Memory keeping

2005-10-30 Thread SourceForge.net
Bugs item #1338264, was opened at 2005-10-26 15:37
Message generated for change (Comment added) made by sin_avatar
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1338264&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: sin (sin_avatar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Memory keeping

Initial Comment:
I execute this code on python 2.4.2 (authentic copy from 
console):
Python 2.4.2 (#1, Oct 26 2005, 14:45:33)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more 
information.
>>> a = range(1,1000)
>>> del a

before i type del - i run top and get (see console output 
below):
16300 sin   2   0   162M   161M poll 0:02 35.76% 
 9.28% python2.4

after del (console below):
16300 sin   2   0   162M   161M poll 0:03  7.18% 
 6.05% python2.4

I tried gc too ... but python didn't free memory. I checked 
this on windows - memory was freed, but interpreter with 
0 defined variables "eat" about 75 Mb!. I think this is bug 
in interpereter core.

some text from dmesg for you:
Copyright (c) 1992-2003 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 
1992, 1993, 1994
The Regents of the University of California. All rights 
reserved.
FreeBSD 4.8-RELEASE #0: Thu Apr  3 10:53:38 GMT 
2003
[EMAIL PROTECTED]:/usr/obj/usr/src/sys/
GENERIC
Timecounter "i8254"  frequency 1193182 Hz
CPU: Pentium III/Pentium III Xeon/Celeron (499.15-MHz 
686-class CPU)
  Origin = "GenuineIntel"  Id = 0x673  Stepping = 3
  Features=0x387f9ff
real memory  = 268369920 (262080K bytes)
avail memory = 255901696 (249904K bytes)


--

>Comment By: sin (sin_avatar)
Date: 2005-10-31 11:15

Message:
Logged In: YES 
user_id=1368129

Certainly, i 'am not a C guru, but i uderstood - if interpreter 
keep more than 100Mb, and not keep useful information - it's 
suxx. Fore example if i use my script as a part Zope portal - it 
would be awful. Certainly my script was just example - but if i 
use mult-thread server wrote on python and create list in each 
thread - i would take memory from system and i cannot give it 
back.

--

Comment By: Tim Peters (tim_one)
Date: 2005-10-28 01:38

Message:
Logged In: YES 
user_id=31435

Space for integer objects in particular lives in an immortal 
free list of unbounded size, so it's certain in the current 
implementation that doing range(1000) will hang on to 
space for 10 million integers forever.  If you don't want that, 
don't do that ;-)  Iterating over xrange(1000) instead will 
consume very little RAM.

--

Comment By: Josiah Carlson (josiahcarlson)
Date: 2005-10-28 01:29

Message:
Logged In: YES 
user_id=341410

>From what I understand, whether or not the Python runtime
"frees" memory (which can be freed) is generally dependant
on platform malloc() and free().

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1338264&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1338264 ] Memory keeping

2005-10-30 Thread SourceForge.net
Bugs item #1338264, was opened at 2005-10-26 02:37
Message generated for change (Comment added) made by josiahcarlson
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1338264&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: sin (sin_avatar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Memory keeping

Initial Comment:
I execute this code on python 2.4.2 (authentic copy from 
console):
Python 2.4.2 (#1, Oct 26 2005, 14:45:33)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more 
information.
>>> a = range(1,1000)
>>> del a

before i type del - i run top and get (see console output 
below):
16300 sin   2   0   162M   161M poll 0:02 35.76% 
 9.28% python2.4

after del (console below):
16300 sin   2   0   162M   161M poll 0:03  7.18% 
 6.05% python2.4

I tried gc too ... but python didn't free memory. I checked 
this on windows - memory was freed, but interpreter with 
0 defined variables "eat" about 75 Mb!. I think this is bug 
in interpereter core.

some text from dmesg for you:
Copyright (c) 1992-2003 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 
1992, 1993, 1994
The Regents of the University of California. All rights 
reserved.
FreeBSD 4.8-RELEASE #0: Thu Apr  3 10:53:38 GMT 
2003
[EMAIL PROTECTED]:/usr/obj/usr/src/sys/
GENERIC
Timecounter "i8254"  frequency 1193182 Hz
CPU: Pentium III/Pentium III Xeon/Celeron (499.15-MHz 
686-class CPU)
  Origin = "GenuineIntel"  Id = 0x673  Stepping = 3
  Features=0x387f9ff
real memory  = 268369920 (262080K bytes)
avail memory = 255901696 (249904K bytes)


--

Comment By: Josiah Carlson (josiahcarlson)
Date: 2005-10-30 22:56

Message:
Logged In: YES 
user_id=341410

Suggested close because and/or:
a) not a bug (integer freelists)
b) platform specific malloc/free behavior on the
list->ob_item member (some platforms will drop to 121M
allocated memory after the deletion)
c) OP didn't listen when it was suggested they use xrange()
instead of range()

--

Comment By: sin (sin_avatar)
Date: 2005-10-30 22:15

Message:
Logged In: YES 
user_id=1368129

Certainly, i 'am not a C guru, but i uderstood - if interpreter 
keep more than 100Mb, and not keep useful information - it's 
suxx. Fore example if i use my script as a part Zope portal - it 
would be awful. Certainly my script was just example - but if i 
use mult-thread server wrote on python and create list in each 
thread - i would take memory from system and i cannot give it 
back.

--

Comment By: Tim Peters (tim_one)
Date: 2005-10-27 12:38

Message:
Logged In: YES 
user_id=31435

Space for integer objects in particular lives in an immortal 
free list of unbounded size, so it's certain in the current 
implementation that doing range(1000) will hang on to 
space for 10 million integers forever.  If you don't want that, 
don't do that ;-)  Iterating over xrange(1000) instead will 
consume very little RAM.

--

Comment By: Josiah Carlson (josiahcarlson)
Date: 2005-10-27 12:29

Message:
Logged In: YES 
user_id=341410

>From what I understand, whether or not the Python runtime
"frees" memory (which can be freed) is generally dependant
on platform malloc() and free().

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1338264&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com