Python not giving free memory back to the os get's me in real problems ...

Steven Howe howe.steven at gmail.com
Wed Apr 25 18:41:28 CEST 2007


Grant Edwards wrote:
> On 2007-04-25, Chris Mellon <arkanes at gmail.com> wrote:
>
>   
>> "Returning memory to the OS" doesn't affect exhaustion of your virtual
>> address space. More likely, your nested loops are just creating more
>> objects than is possible to hold within a single process.
>>     
>
> I'm a bit fuzzy on this, but I don't think there _is_ a
> practical way to "return memory to the OS" in many OSes.  For
> example in Unix the C library uses the sbrk() call to increase
> the size of the data segment when additional memory is needed
> to handle soemthing like malloc() calls.  
>
> In theory, one can use brk() to reduce the size of the data
> segment, but I think making the segment smaller will produce
> undefined behavior if any of the standard C library's dynamic
> memory routines (e.g. malloc/free) have ever been used by the
> program prior to the call to brk().
>
>   
Interesting questions. What happens when an object is 'cleaned' up by
using the 'del' command. Does the memory space stay in the python
process, get handed back to the OS, or some combination of both?
I remember 'C' on VMS at least, could be coerced into return memory on
block boundaries. 'C++' was suppose to have garbage collect, but I was
always doubtful it worked well.

sph




More information about the Python-list mailing list