Re: Reference Counts

2006-05-19 Thread Tim Peters
[raghu, on Heiko Wundram's test program: import sys x = {} i = 0 def test(): global x, i x[i] = "test" i += 1 del x[i-1] # Properly clean up x. for j in xrange(1): print "Before", j, ":", sys.gettotalrefcount() test() print "After", j, ":", sys.gettotalrefcount() ] > Hm

Re: Reference Counts

2006-05-18 Thread raghu
Hmm... I tried the gc.collect(). It aint helping. The reference count still keeps growing till 5 after it which it drops. As you said, it is not gonna hurt right away. The only downside in that mysterious up and down thingie is that , we could get to a wrong conclusion about a leak, if we ran the

Re: Reference Counts

2006-05-18 Thread Heiko Wundram
Am Donnerstag 18 Mai 2006 09:33 schrieb raghu: > However, the 'non-leaky' one showed a funny trend ...it kept increasing > the totalrefcount for five iterations (see 1 thru 5) and then dropped > down by 5 ( See Before 5 : 16584 > After 5 : 16580 ) suddenly and again increase as shown below. However

Re: Reference Counts

2006-05-18 Thread raghu
Heiko, Thanks for the explanation. I understood the idea of 1 being interned. Also I understood the globals vars having a reference in the internal dict. I ran the "leaky" version of the program and yes...it showed a progressively increasing totalrefcount as below. Before 0 : 16579 After 0 : 1658

Re: Reference Counts

2006-05-17 Thread Heiko Wundram
Am Donnerstag 18 Mai 2006 08:28 schrieb raghu: > #!/usr/bin/python > > import sys > global a > > print "Total Reference count at the start =",sys.gettotalrefcount() > a=1 > print "a ref count =",sys.getrefcount(a) > b=a > print "a ref count =",sys.getrefcount(a) > > del a > del b > > print "Total R