Garbage collection working improperly?

Jay O'Connor joconnor at cybermesa.com
Fri Nov 21 10:40:07 EST 2003


Diez B. Roggisch wrote:

> Hi,
>
>> Builds up a great list in memory and immediately deletes it. 
>> Unfortunately
>
>
> if all you want is to create a loop, use xrange instead of range - it 
> won't create that huge list.
>
>> the task manager shows me that i allocated about 155MB in memory before
>> del(), but del only releases about 40MB of them so i'm leaving about 
>> 117 MB
>> of reserved memory after deleting the list.
>> I'm using python 2.2.3 on WinXP.
>> Any ideas about that? How can i dealloc the left memory space?
>
>
> Nope, no idea - the only thing that I can think of is that python not 
> necessarily releaseses the memory because it uses its own allocation 
> scheme. I don't know that for sure, but I definitely would go for such 
> a thingy if I was to implement a virtual machine.
> Its like in JAVA - each object instantiation and destruction isn't 
> paired with system malloc/free calls, but some internal memory manager 
> deals with that. And if it rans out of space, it will request more 
> from the system.



I kinda like VisualWorks Smalltalk's approach.  It uses a system whereby 
new objects are scavenged aggresivly and objects that survive the 
scavenger are moved to a different memory space that is not GC'ed nearly 
as much.  (New objects tend to have short lives..objects that survive 
several generations of scavenging tend to live longer) When it's memory 
reaches a threshold, it makes a decision as to whether to either request 
more from the OS or  to GC the old object memory space in an  attempt to 
free more memory.  The nice part is that you can configure a. how much 
memory it starts with b. at what point the threshold is set for and 
c.the weighting of the algorithim to determine whether to GC or allocate


Take care,
Jay





More information about the Python-list mailing list