|
|
||||||
|
#1
|
|
|
|
|
Hi.
Please check this simple test code. --------------------- class TestA: def __init__(self): print "init TestA" def __del__(self): print "del TestA" def SetEvent(self, event): self.event = event class TestB: def __init__(self): print "init TestB" self.testA = TestA() self.testA.SetEvent(self.Test) def __del__(self): print "del TestB" def Test(self): pass testB = TestB() del testB --------------------- I want to run this code that destroy testB and testB's member object testA. But no object destroy. I know testA increase testB's reference count, but why wouldn't python decrease testB's reference count? Had I do wrong something? |
|
|
|
#2
|
|
|
|
|
"Minkyu Kim" <levites> wrote in message
news:01ed [..] > pass > > testB = TestB() > del testB > --------------------- > > I want to run this code that destroy testB and testB's member object > testA. But no object destroy. I know testA increase testB's reference > count, but why wouldn't python decrease testB's reference count? Had I > do wrong something? You created a circular reference loop of objects with __del__ methods. Without adding 'del testB.testA' to break the loop, before the testB deletion, the reference counts never go to 0. I believe the gc garbage collector will also leave the loop alone because of the __del__ methods. Trying to watch gc in action stops it (!) because __del__ methods can do (and have done) things that mess up the gc process, so gc no longer tries when they are present. So break the loop as indicated above. Terry J. Reedy |
|
|
| Similar Threads | |
| handling of regexp objects that aren't referenced by variables,arrays, tables or objects Hi, first of all I have to say I'm relatively unexperienced with Ruby and also new to regular expressions. This causes me some problems: I'm parsing text files and am... |
|
| destroy referenced objects Hello, pretend some noob has (in a fake-static class) provided the following method public static kill_object($obj) { if (!is_object($obj)) return false; |
|
| sizeof an object that have same base class as member objects. Note: This problem is related to gcc but after some back and forth in group gnu.gcc.help it seems to have morph into more of a c++ specificiation question, hence the... |
|
| Accessing a non referenced member through a member object in php 4.4.4 creates copy of original object Quite difficult to create a meaningful title on this post. I'll try to explain the problem in words first, and some example code follows. BTW. this is not a problem in PHP 5... |
|
| Missing AD objects - Corrupted Member object Now that I have ultrasound up and working I've been dealing with fixing all my DFS issues and just ran into something that I'm not too sure about. I'm getting a report in... |
|
|
All times are GMT. The time now is 09:09 PM. | Privacy Policy
|