On Mon, 27 Aug 2007 07:18:26 -0700, rfv-370 wrote: > have made the following small test: > > Before starting my test my UsedPhysicalMemory(PF): 555Mb > >>>>tf=range(0,10000000) PF: 710Mb ( so 155Mb for my List) >>>> tf=[0,1,2,3,4,5] PF: 672Mb (Why? Why the remaining 117Mb is >>>> not freed?) >>>> del tf PF: 672Mb (unused memory not freed) > > So changing the list contents and/or deleting the list changes > nothing...from a memory point of view.
>From the OS memory point of view to be precise. Although here the integer cache applies as Alex pointed out, in the general case memory might be kept allocated by Python to be re-used later. The Python allocator is better suited for frequent allocation and deallocation of many small objects than `malloc()` from the C standard library is. And even a `free()` in the C standard library doesn't guarantee that memory is given back to the OS and reported as free memory again. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list