Freeing memory from Python lists!
Chad Everett
chat at linuxsupreme.homeip.net
Wed Jul 11 17:48:50 EDT 2001
On 11 Jul 2001 14:53:06 -0500, Chris Spencer <clspence at one.net> wrote:
> I can confirm these results. Why would a deleted list retain 90% of its
>memory usage after being deleted? Sounds like a pointer is getting lost
>somewhere.
>
>Chris.
>
>On 11 Jul 2001 11:41:25 -0700, msimpson at ioindustries.com (Mike Simpson) wrote:
>
>>I can't figure out how to free the memory used in the creation of a
>>large list in Python.
>>I am running the Python 2.1 interpreter on Windows 2000 Professional
>>to run the following piece of code:
>>
>>result = []
>>for count in xrange(510*478):
>> result.append(count)
>>del result
>>
>>By using Windows Task Manager I was able to determine that 4332K of
>>memory was used up until the end of the for loop, but only 960K of
>>memory was returned to the system after the call to "del". Is there
>>any way to return the other 3372K of memory to the system without
>>quitting the Python interpreter?
>>
Nothing has been lost. As other responses have pointed out, you are seeing
a manifestation of the OS memory management algorithms. To show you that
nothing has been "lost" do the following:
1. run python and get a python prompt
2. look at your memory allocation
3. do your:
result = []
for count in xrange(510*478):
result.append(count)
4. look at memory usage
5. delete the result list
del result
6. look at memory usage
7. now build the list again
result = []
for count in xrange(510*478):
result.append(count)
8. look at memory usage and you'll see it has only gone back up to the same
amount of memory at step 4.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
More information about the Python-list
mailing list