doctrine2 - Doctrine 2 memory hogging -
i'm using doctrine 2 zf2 project, i'm getting weird problem server cpu , memory. , server crashes.
i'm getting lot of sleep state querys , seem not cleaned.
mysql> show processlist; +---------+--------------+-----------+------------------+----------------+------+--------------------+------------------------------------------------------------------------------------------------------+ | id | user | host | db | command | time | state | info | +---------+--------------+-----------+------------------+----------------+------+--------------------+------------------------------------------------------------------------------------------------------+ | 2832346 | leechprotect | localhost | leechprotect | sleep | 197 | | null | | 2832629 | db_user | localhost | db_exemple | sleep | 3 | | null | | 2832643 | db_user | localhost | db_exemple | sleep | 3 | | null | | 2832646 | db_user | localhost | db_exemple | sleep | 3 | | null | | 2832664 | db_user | localhost | db_exemple | sleep | 154 | | null | | 2832666 | db_user | localhost | db_exemple | sleep | 153 | | null | | 2832669 | db_user | localhost | db_exemple | sleep | 152 | | null | | 2832674 | db_user | localhost | db_exemple | sleep | 7 | | null | | 2832681 | db_user | localhost | db_exemple | sleep | 1 | | null | | 2832683 | db_user | localhost | db_exemple | sleep | 4 | | null | | 2832690 | db_user | localhost | db_exemple | sleep | 149 | | null | (.......)
also, seems php gc not cleaning objects memory, or kill processes. there way disable cache system? improve use of resorces=
most querys similar to:
$query = $this->createquerybuilder('i'); $query->innerjoin('\application\relation', 'r', 'with', 'r.child = i.id'); $query->innerjoin('\application\taxonomy', 't', 'with', 't.id = r.taxonomy'); $query->where('t.type = :type')->setparameter('type', $relation); $query->groupby('i.id'); $items = $query->getquery()->getresult(2);
thanks in advance.
firstly check mysql's wait_timout variable. documentation:
wait_timeout : number of seconds server waits activity on noninteractive connection before closing it.
in normal flow (which not using persistent connections), php closes connection automatically after script execution. ensure there no sleeping threads; @ end of script close connection:
$entitymanager->getconnection()->close();
if these queries running in big while/for loop, might want read doctrine 2 batch processing documentation.
Comments
Post a Comment