I am using codeigniter and PHP to build a web app and there are lot of objects that I have to define/use inside models due to large number of queries that I have to execute. Sometime I have to use same object multiple times inside a loop, for example:
$dbData = $this->mydb->query($dbQuery);
if($dbData->num_rows() >0 ){ //check if rows were returned
$dbResult = $dbData->result();
foreach( $dbResult as $index => $row){
$dbArray[$row->JOB_NAME_STG] = $row->REC_LOADED;
}
In general programming practice you should nullify the objects once they are no longer required but I haven't been able to find any detail on the best way to ensure that all the objects are nullified avoiding memory leaks for codeigniter or php in general.
Is assigning NULL to an object at the end of the function sufficient?
$dbData = $this->mydb->query($dbQuery);
$dbData = NULL;
Or codeigniter has more efficient way of ensuring that there are no memory leaks.
Should object be nullified inside a loop before using to ensure there is no memory leak?
Any pointers in the direction will be appreciated. Thanks!!!