memory leak problem with arrays
Serge.Orlov at gmail.com
Thu Jun 15 01:18:47 CEST 2006
> Serge Orlov wrote:
> > sonjaa wrote:
> > > Hi
> > >
> > > I'm new to programming in python and I hope that this is the problem.
> > >
> > > I've created a cellular automata program in python with the numpy array
> > > extensions. After each cycle/iteration the memory used to examine and
> > > change the array as determined by the transition rules is never freed.
> > > I've tried using "del" on every variable possible, but that hasn't
> > > worked.
> > Python keeps track of number of references to every object if the
> > object has more that one reference by the time you use "del" the object
> > is not freed, only number of references is decremented.
> > Print the number of references for all the objects you think should be
> > freed after each cycle/iteration, if is not equal 2 that means you are
> > holding extra references to those objects. You can get the number of
> > references to any object by calling sys.getrefcount(obj)
> thanks for the info. I used this several variables/objects and
> discovered that little counters i.e. k = k +1 have many references to
> them, up tp 10000+.
> Is there a way to free them?
Although it's looks suspicious, even if you manage to free it you will
gain only 12 bytes. I think you should concentrate on more fat
More information about the Python-list