From: Mattias Michaux Date: Thu, 19 May 2016 15:26:52 +0000 (+0200) Subject: Drasticly reduce memory usage during tests. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b6e2f1b35ea78579f8cb228564f970a1e72b0681;p=civicrm-core.git Drasticly reduce memory usage during tests. --- diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index ee43b3253f..79861e2286 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -129,26 +129,26 @@ class CRM_Core_DAO extends DB_DataObject { if ($fkDAO->find(TRUE)) { $this->$dbName = $fkDAO->id; } - unset($fkDAO); + $fkDAO->free(); } elseif (in_array($FKClassName, CRM_Core_DAO::$_testEntitiesToSkip)) { $depObject = new $FKClassName(); $depObject->find(TRUE); $this->$dbName = $depObject->id; - unset($depObject); + $depObject->free(); } elseif ($daoName == 'CRM_Member_DAO_MembershipType' && $fieldName == 'member_of_contact_id') { // FIXME: the fields() metadata is not specific enough $depObject = CRM_Core_DAO::createTestObject($FKClassName, array('contact_type' => 'Organization')); $this->$dbName = $depObject->id; - unset($depObject); + $depObject->free(); } else { //if it is required we need to generate the dependency object first $depObject = CRM_Core_DAO::createTestObject($FKClassName, CRM_Utils_Array::value($dbName, $params, 1)); $this->$dbName = $depObject->id; - unset($depObject); + $depObject->free(); } } @@ -481,6 +481,7 @@ class CRM_Core_DAO extends DB_DataObject { $event = new \Civi\Core\DAO\Event\PostDelete($this, $result); \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("DAO::post-delete", $event); + $this->free(); return $result; } diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index aa403ce360..38f08898d5 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -857,6 +857,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { for ($i = 0; $i < 30; $i++) { $baoObj = CRM_Core_DAO::createTestObject($baoString, array('currency' => 'USD')); $ids[] = $baoObj->id; + $baoObj->free(); } // each case is array(0 => $inputtedApiOptions, 1 => $expectedResultCount) @@ -897,6 +898,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { for ($i = 0; $i < 3 - $totalEntities; $i++) { $baoObj = CRM_Core_DAO::createTestObject($baoString, array('currency' => 'USD')); $ids[] = $baoObj->id; + $baoObj->free(); } $totalEntities = 3; }