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-20754 - Clear memory leak in CSV CLI import #10537

Merged
merged 3 commits into from
Jul 17, 2017

Conversation

MegaphoneJon
Copy link
Contributor

@MegaphoneJon MegaphoneJon commented Jun 21, 2017

@seamuslee001
Copy link
Contributor

@PalanteJon can you fix the style error https://test.civicrm.org/job/CiviCRM-Core-PR/15884/checkstyleResult/new/

@@ -430,6 +430,14 @@ public function run() {
continue;
}
$this->row++;
if ($this->row % 1000 == 0) {
// Reset PEAR_DB_DATAOBJECT cache to prevent memory leak
$GLOBALS['_DB_DATAOBJECT']['RESULTS'] = array();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any side effects of clearing the results cache? If not then would it be an option to disable it completely? Presumably this would also resolve the large import problem that this ticket addresses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mickadoo No side effects in this scenario, no. However, I can't guarantee there would be no side effects Civi-wide, so I don't think disabling the cache is a worthwhile endeavor.

This object is the one that CRM_Core_DAO is extending, so it's very low-level. While there DOES appear to be an inherited class called DB_DataObject_Overload that we could extend instead, I think we'd find it rather difficult to only disable the cache when it was relevant.

@totten @eileenmcnaughton If you're more familiar with the DB_DataObject->_resultFields property than I am, please feel free to comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we normally use CRM_Core_DAO::freeResult() - which erm mostly works

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Eileen! CRM_Core_DAO::freeResult() looks slower but functionally equivalent - that is, there's still no "disable the $_resultFields" option. However, that method might result in lower memory use. I have some massive datasets at the moment, so next week when I'm not mid-import, I will do speed and RAM usage tests to compare.

@MegaphoneJon
Copy link
Contributor Author

I ran some tests tonight and confirmed that CRM_Core_DAO::freeResult() performs similarly (within a margin of error) to my original patch. In the interests of DRY, I updated this patch with the change.

@seamuslee001
Copy link
Contributor

Looks good to me makes sense

@monishdeb
Copy link
Member

Yup works fine. Merging it now

@monishdeb monishdeb merged commit 8bad8b1 into civicrm:master Jul 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants