Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-19798 fix memory leak #11615

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions CRM/Contact/BAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -1000,10 +1000,6 @@ public static function deleteContact($id, $restore = FALSE, $skipUndelete = FALS
CRM_Utils_Hook::post('delete', $contactType, $contact->id, $contact);
}

// also reset the DB_DO global array so we can reuse the memory
// http://issues.civicrm.org/jira/browse/CRM-4387
CRM_Core_DAO::freeResult();

return TRUE;
}

Expand Down
3 changes: 0 additions & 3 deletions CRM/Contact/Import/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@ public function run(
break;
}

// clean up memory from dao's
CRM_Core_DAO::freeResult();

// see if we've hit our timeout yet
/* if ( $the_thing_with_the_stuff ) {
do_something( );
Expand Down
1 change: 0 additions & 1 deletion CRM/Core/BAO/RecurringEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,6 @@ static public function triggerUpdate($event) {
}

$updateDAO = CRM_Core_DAO::cascadeUpdate($daoName, $obj->id, $entityID, $skipData);
CRM_Core_DAO::freeResult();
}
else {
CRM_Core_Error::fatal("DAO Mapper missing for $entityTable.");
Expand Down
7 changes: 7 additions & 0 deletions CRM/Core/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ public function __construct() {
$this->__table = $this->getTableName();
}

/**
* Class destructor.
*/
public function __destruct() {
$this->free();
}

/**
* Empty definition for virtual function.
*/
Expand Down
3 changes: 0 additions & 3 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,6 @@ public static function getRowsElementsAndInfo($mainId, $otherId, $checkPermissio
$otherTree = CRM_Core_BAO_CustomGroup::getTree($main['contact_type'], NULL, $otherId, -1,
CRM_Utils_Array::value('contact_sub_type', $other), NULL, TRUE, NULL, TRUE, $checkPermissions
);
CRM_Core_DAO::freeResult();

foreach ($otherTree as $gid => $group) {
$foundField = FALSE;
Expand Down Expand Up @@ -2256,8 +2255,6 @@ protected static function dedupePair(&$migrationInfo, &$resultStats, &$deletedCo
// pair may have been flipped, so make sure we delete using both orders
CRM_Core_BAO_PrevNextCache::deletePair($mainId, $otherId, $cacheKeyString, TRUE);
}

CRM_Core_DAO::freeResult();
}

}
13 changes: 13 additions & 0 deletions tests/phpunit/api/v3/EntityTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ public function testIndividualEntityTagGet() {
$this->callAPIAndDocument('entity_tag', 'get', $paramsEntity, __FUNCTION__, __FILE__);
}

/**
* Test memory usage does not escalate crazily.
*/
public function testMemoryLeak() {
$start = memory_get_usage();
for ($i = 0; $i < 100; $i++) {
$this->callAPISuccess('EntityTag', 'get', []);
$memUsage = memory_get_usage();
}
$max = $start + 2000000;
$this->assertTrue($memUsage < $max, "mem usage ( $memUsage ) should be less than $max (start was $start) ");
}

/**
* Test tag can be added to a household.
*/
Expand Down