GC and security

Aahz aahz at pythoncraft.com
Wed Aug 30 23:00:12 EDT 2006


In article <44F61EEB.8040207 at optonline.net>,
Les Schaffer  <schaffer at optonline.net> wrote:
>
>so i am curious. so long as i drop all reference to the passphrase
>string(s), eventually it gets garbage collected and the memory recycled.
>so "before long" the phrase is gone from memory.

Assuming you're talking about CPython, strings don't really participate
in garbage collection.  Keep in mind that the primary mechanism for
reaping memory is reference counting, and generally as soon as the
refcount for an object goes to zero, it gets deleted from memory.
Garbage collection only gets used for objects that refer to other
objects, so it would only apply if string refcounts are being held by
GC-able objects.

Also keep in mind, of course, that deleting objects has nothing to do
with whether the memory gets overwritten...
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

I support the RKAB



More information about the Python-list mailing list