Memory leak in PHP with Symfony + Doctrine
- by Nicklas Ansman
I'm using PHP with the Symfony framework (with Doctrine as my ORM) to build a spider that crawls some sites.
My problem is that the following code generates a memory leak:
$q = $this -> createQuery('Product p');
if($store) {
$q
-> andWhere('p.store_id = ?', $store -> getId())
-> limit(1);
}
$q -> andWhere('p.name = ?', $name);
$data = $q -> execute();
$q -> free(true);
$data -> free(true);
return NULL;
This code is placed in a subclass of Doctrine_Table. If I comment out the execute part (and of course the $data - free(true)) the leak stops. This has led me to the conclusion that it's the Doctrine_Collection that's causing the leak.
Any ideas on what I can do to fix this? I'd be happy to provide more info on the problem if you need it.
Regards Nicklas