[Tutor] how is memory de-allocated?

Lloyd Kvam pythonTutor at venix.com
Sat Apr 10 15:26:43 EDT 2004


There is automatic garbage collection as in Java.  IF we no longer need
an object we can delete the name we use to refer to the object.  If that
was the last reference then the memory used by that object will be
reclaimed.

The example below creates a tuple and uses the name x to refer to that
tuple.  Once the name is deleted, the garbage collection will detect
that the tuple can no longer be used and will reclaim the memory.

>>> x = (1,2,3)
>>> x
(1, 2, 3)
>>> del x
>>> x
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'x' is not defined

On Sat, 2004-04-10 at 13:53, dlafrance at cs-linux.ubishops.ca wrote:
> Hi,
> 
> I would like know how is memory de-allocated?
> 
> Through explicit programmer instruction like c++ or via garbage collection
> like Java
> 
> And if it is possible can you give me an example
> 
> Thanks.
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 

Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-653-8139
fax:	801-459-9582




More information about the Tutor mailing list