From: Jon goldberg Date: Wed, 21 Jun 2017 14:07:31 +0000 (-0400) Subject: CRM-20754 - Clear memory leak in CSV CLI import X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6c07d162053e541fd8149b222898979652c341a5;p=civicrm-core.git CRM-20754 - Clear memory leak in CSV CLI import --- diff --git a/bin/cli.class.php b/bin/cli.class.php index dbcc5e9caf..f450b74b51 100644 --- a/bin/cli.class.php +++ b/bin/cli.class.php @@ -430,6 +430,14 @@ class civicrm_cli_csv_file extends civicrm_cli { continue; } $this->row++; + if ($this->row % 1000 == 0) { + // Reset PEAR_DB_DATAOBJECT cache to prevent memory leak + $GLOBALS['_DB_DATAOBJECT']['RESULTS'] = array(); + $GLOBALS['_DB_DATAOBJECT']['RESULTSEQ'] = 1; + $GLOBALS['_DB_DATAOBJECT']['RESULTFIELDS'] = array(); + // Forces garbage collection + memory_get_usage(true); + } $params = $this->convertLine($data); $this->processLine($params); }