Answers.Body: <p>We have been running this patch in production for some months to address the memory leak</p>
  
  <p><a href="https://github.com/civicrm/civicrm-core/pull/11615" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/pull/11615</a></p>
  
  <p>When we first deployed it we hit a bug on the use of cloning the DAO in export. I removed that place however there is one remaining when exporting related contacts and I closed the PR until I had a chance to address that</p>
  
  <pre><code>      $allRelContactArray[$rel][$allRelContactDAO-&gt;refContact] = clone($allRelContactDAO);
  </code></pre>
  
  <p>I've now updated for that issue &amp; re-submitted - <a href="https://github.com/civicrm/civicrm-core/pull/12276" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/pull/12276</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-06T20:58:58.080Z
Answers.LastActivityDate: 2018-06-06T21:43:43.330Z
Answers.LastEditDate: 2018-06-06T21:43:43.330Z
Answers.UserDisplayName: user4278
Body: <p>I am trying to use PHP on the Command Line to import 90,000 contacts to Civi 5.0. It seem like there is a memory like when calling:
  civicrm_api3('Contact', 'create', $usrArray); </p>
  
  <p>Does anyone know what code in the api could be causing this?</p>
  
  <p>The looping of the CSV has been written not to use up more memory than the line being read, this has been tested alone with memory_get_usage();</p>
  
  <p>Best,
  Joel</p>
  
Tags: <api>
Title: Memory leak in API create Contact
ThreadText: # Memory leak in API create Contact
  
  (Asked by: username_0 on 2018-06-06)
  
  I am trying to use PHP on the Command Line to import 90,000 contacts to Civi 5.0. It seem like there is a memory like when calling:
  civicrm\_api3('Contact', 'create', $usrArray);
  
  Does anyone know what code in the api could be causing this?
  
  The looping of the CSV has been written not to use up more memory than the line being read, this has been tested alone with memory\_get\_usage();
  
  Best,
  username_0
  
  **Tags:** api
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-06-06. Score: 4 | Accepted answer
  
  We have been running this patch in production for some months to address the memory leak
  https://github.com/civicrm/civicrm-core/pull/11615
  When we first deployed it we hit a bug on the use of cloning the DAO in export. I removed that place however there is one remaining when exporting related contacts and I closed the PR until I had a chance to address that
        $allRelContactArray[$rel][$allRelContactDAO->refContact] = clone($allRelContactDAO);
  
  I've now updated for that issue & re-submitted - https://github.com/civicrm/civicrm-core/pull/12276
  
  
  ---
  
  