Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

Wong Wah Meng-R32813 r32813 at freescale.com
Wed Mar 6 07:36:04 EST 2013


Thanks for youre reply. I built python 2.7.1 binary myself on the HP box and I wasn't aware there is any configuration or setup that I need to modify in order to activate or engage the garbage collection (or even setting the memory size used). Probably you are right it leaves it to the OS itself (in this case HP-UX) to clean it up as after python removes the reference to the address of the variables the OS still thinks the python process should still owns it until the process exits. 

Regards,
Wah Meng 

-----Original Message-----
From: Python-list [mailto:python-list-bounces+wahmeng=freescale.com at python.org] On Behalf Of Terry Reedy
Sent: Wednesday, March 06, 2013 7:00 PM
To: python-list at python.org
Subject: Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

On 3/6/2013 5:11 AM, Wong Wah Meng-R32813 wrote:
> Hello there,
>
> I am using python 2.7.1 built on HP-11.23 a Itanium 64 bit box.
>
> I discovered following behavior whereby the python process doesn't 
> seem to release memory utilized even after a variable is set to None, 
> and "deleted". I use glance tool to monitor the memory utilized by 
> this process. Obviously after the for loop is executed, the memory 
> used by this process has hiked to a few MB. However, after "del" is 
> executed to both I and str variables, the memory of that process still 
> stays at where it was.

Whether memory freed by deleting an object is returned to and taken by the OS depends on the OS and other factors like like the size and layout of the freed memory, probably the history of memory use, and for CPython, the C compiler's malloc/free implementation. At various times, the Python memory handlers have been rewritten to encourage/facilitate memory return, but Python cannot control the process.

> for i in range(100000L):
>      str=str+"%s"%(i,)
> i=None; str=None   # not necessary
 > del i; del str

Reusing built-in names for unrelated purposes is generally a bad idea, although the final deletion does restore access to the builtin.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list