Re: [Beginner] delete items of [] also from memory
From: Duncan Booth (duncan.booth_at_invalid.invalid)
Date: 11/23/04
- Next message: Denis S. Otkidach: "Re: split large file by string/regex"
- Previous message: Duncan Booth: "Re: Microsoft Patents 'IsNot'"
- In reply to: Peter: "Re: [Beginner] delete items of [] also from memory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Nov 2004 09:47:45 GMT
Peter wrote:
> "Birgit Rahm" <br_y@yahoo.de> wrote in message
> news:<cns50t$5ip$05$1@news.t-online.com>...
>> Hello newsgroup,
>>
>> I am a beginner, so I am asking maybe immoderate questions.
>> I want to delete a [] variable, after filling it with complex
>> objects. How should I do it?
>> e.g.
>> AAA = []
>> AAA = [B, C, D, E, F]
>> Can I
>> 1) AAA = []
>> 2) del AAA[0:]
>> 3) ?
>> whats about the computers memory, will it get free? Or will it get
>> more and more while Python is running?
>
> I too am a novice, so am prepared to be corrected if this is wrong.
>
> I don't think you need to worry - Python handles memory allocation
> automatically. Names are not specifically allocated to memory, and
> when the last reference to a name is deleted all the associated memory
> is freed.
It depends on what the original poster meant by 'complex' objects.
Objects with circular references may not be freed until the garbage
collector kicks in, and objects with circular references and a __del__
method may not be freed at all. However, provided you avoid writing __del__
methods on such objects, the memory may not be freed immediately but it
will be freed eventually.
Objects which are not involved in any cyclic references will be freed, as
you say, as soon as the last reference goes.
('Freed' in this context means released for reuse by Python --- don't ever
expect the process to release memory back to the rest of the system.)
- Next message: Denis S. Otkidach: "Re: split large file by string/regex"
- Previous message: Duncan Booth: "Re: Microsoft Patents 'IsNot'"
- In reply to: Peter: "Re: [Beginner] delete items of [] also from memory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|