Memory management
Larry Whitley
ldw at us.ibm.com
Tue Jul 25 16:50:33 EDT 2000
Reading through Quick Python. For those who want to get explicit about
memory management, it looks like the authors advise saying "object = None"
rather than "del object". Is that the correct interpretation? Presumably
Python will then call object.__del__() when the garbage collector runs.
Larry
"Michael Hudson" <mwh21 at cam.ac.uk> wrote in message
news:m3zon6asl3.fsf at atrus.jesus.cam.ac.uk...
> "Larry Whitley" <ldw at us.ibm.com> writes:
>
> > I'm running out of virtual memory on my NT 4.0 system running a longish
> > python script. Python says "memory error" and quits. NT shows the
> > application using 130+ megabytes. I have 192 megabytes on the system so
it
> > seems like a rational number. I suspect that this means that I have a
> > memory leak in my code.
> >
> > In the outer loop of my code, I create a object of a class I have
defined.
> > The outer loop reads records from a trace file and hands them to the
object
> > created for execution. This first level object creates a number of
second
> > level objects of a different class while processing the trace file.
When
> > the trace file is complete, the outer loop deletes the first level
object.
> > I am expecting that to cause all of the references held by that object,
and
> > those of the second level objects is created to go to zero.
> >
> > Here's a programmtic description:
> [schnipp]
> > My question: How do I get rid of the memory used by o1 and by o1a, o1b,
etc
> > within o1 when each trace file is processed?
>
> I'm guessing that you have reference cycles; these can be fun to find,
> and even more fun to eliminate. However the code you posted didn't
> create any cycles, so either post some more, or go and stare at your
> code some (ask Gordon about the "hypnotising bricks" approach...).
>
> It's also possible that Python 2.0 will have a better garbage
> collector.
>
> Cheers,
> M.
>
> --
> Very rough; like estimating the productivity of a welder by the
> amount of acetylene used. -- Paul Svensson, comp.lang.python
> [on the subject of the measuring programmer productivity by LOC]
More information about the Python-list
mailing list