Re: reference counting and garbage collection

From: Date: Fri, 03 Nov 2000 22:13:36 +0000
Subject: Re: reference counting and garbage collection
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-23649@lists.php.net to get a copy of this message
> I'm pretty sure this person doesn't quite know what they're talking about. > http://www.zend.com/zend/art/ref-count.php is an article > by Zeev that has a lot of info on reference counting. There are a couple > issues they mention with respect to being careful with code, > but I've never seen anything regarding this. In fact, PHP4 in particular > has been, in my experience, the only platform I've never had any garbage > collection > issues with at all, and I don't unset() things all that much. Yes, but in particular, what we're talking about is circular references. I'm not totally sure why this would cause a problem, but that's the reasoning this guy gave. He said that since he has circular references, (that is, a child had a reference to its parent, and that parent had a reference to that child), it would cause a memory leak. I don't see how it's a problem, but I want to make sure. I've been running my own NavNode class (an n-ary tree with circular references) for some time and it doesn't seem to cause any problems, but I want to make sure. Dean. > Dean Hall wrote: > > > I read something today from someone else's source that made me think. He > > said that since PHP uses reference counters, you need to 'unset' all your > > references before you exit your script. In particular, he was talking about > > an n-ary tree data structure he had made. He insisted in his comments that > > before the script ends, you call his cleanup method that goes through the > > entire tree and 'unset's all the references to parents and children. > > > > I'm worried about this, because I wrote an n-ary tree data structure as a > > navigation hierarchy for my website <http://www.apt7.com/src/NavNode.txt>. > > It uses references to keep track of its parent and its children. Do I need > > to unset these before script execution ends? Will I end up with memory > > leaks? I'm not familiar enough with the innards of PHP to know. > > > > Thanks to any brave enough to tackle this. > > Dean. > > -- > ========================== > Michael Kimsal > http://www.tapinternet.com > 734-480-9961 > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#23649) next »