Login | Register
My pages Projects Community openCollabNet

propel
Reply to message

* = Required fields
* Subject
* Body
Attachments
Send reply to
Topic
Author (directly in email)
Please type the letters in the image above.

Original message

Author Alan Pinstein <apinstein@mac.com>
Full name Alan Pinstein <apinstein@mac.com>
Date 2005-12-06 08:43:38 PST
Message Ugh. I found the leak... I think it's a bit tricky....

So, I have an MlsProperty which has 0-N MlsPropertyFeatures.

Here's a little debug output from a script that imports 10
properties. All but one have 1+ MlsPropertyFeatures...

Importing: ./savedData.txt
new MlsProperty
new MlsPropertyFeature
Adding MlsPropertyFeature to MlsProperty
new MlsProperty
new MlsPropertyFeature
Adding MlsPropertyFeature to MlsProperty
new MlsProperty
new MlsPropertyFeature
Adding MlsPropertyFeature to MlsProperty
new MlsProperty
destroy MlsProperty **** this is the only one to get destroyed
properly, and it's the only one that has 0 MlsPropertyFeature's
new MlsProperty
new MlsPropertyFeature
Adding MlsPropertyFeature to MlsProperty
new MlsProperty
new MlsPropertyFeature
Adding MlsPropertyFeature to MlsProperty
new MlsProperty
new MlsPropertyFeature
Adding MlsPropertyFeature to MlsProperty
new MlsProperty
new MlsPropertyFeature
Adding MlsPropertyFeature to MlsProperty
new MlsProperty
destroy MlsProperty
new MlsProperty
destroy MlsProperty
Done processing './savedData.txt'
====================​========> Leaked: 4039.2
[script ends, php cleanup follows]
destroy MlsProperty
destroy MlsPropertyFeature
destroy MlsProperty
destroy MlsPropertyFeature
destroy MlsProperty
destroy MlsPropertyFeature
destroy MlsProperty
destroy MlsPropertyFeature
destroy MlsProperty
destroy MlsPropertyFeature
destroy MlsProperty
destroy MlsPropertyFeature
destroy MlsProperty
destroy MlsPropertyFeature

====================​====================​====

So, the problem is:

     // in BaseMlsProperty.php
     public function addMlsPropertyFeatur​e(MlsPropertyFeature​ $l)
     {
         print "Adding MlsPropertyFeature to MlsProperty\n";
         $this->collMlsPr​opertyFeatures[] = $l;
         $l->setMlsProperty($this);
     }

     // in BaseMlsPropertyFeature.php
     public function setMlsProperty($v)
     {


         if ($v === null) {
             $this->setMlsPro​pertyId(NULL);
         } else {
             $this->setMlsPro​pertyId($v->getM​lsPropertyId());
         }


         $this->aMlsProperty = $v;
     }

A circular reference is being created... since PHP doesn't have weak
references I am not sure how to fix this... off the top of my head I
don't see how this circular reference can be eliminated without
losing functionality.

There seems to be a lot of talk on php lists about the circular
reference problem. The php-dev guys seem to think it's not a bug,
which I suppose "technically" it isn't since the memory is freed, but
it is then certainly a language deficit for doing big OO projects.

Thoughts?

Alan

On Dec 6, 2005, at 8:49 AM, Hans Lellelid wrote:

> Yes -- Creole (CVS) will coincide w/ Propel release. Thanks for
> looking
> into the leaking, Alan!