public function foo($file1, $file2){ $obj = new Obj(); $data = array(); $data[] = $obj->importAFile($file1); $data[] = $obj->importAFile($file2); return $data; }
Does the memory allocated for $obj get freed after the return?
If not how can I free it?
It manages memory for you. You might have a problem only when there are some circular references between your objects