title: Which is more efficient: curl_easy_perform() in a multi-threaded program or curl_multi_perform() in a single threaded program?
body: <p>I am working on a program where I am required to download a large amount of JSON files from different URLs.</p>
  
  <p>Currently, my program creates multiple threads, and in each thread, it calls the LibCurl easy_perform() function but I am running into issues where the program fails <em>occasionally</em> with an error of "double free". It seems to be some sort of Heisenbug but I have been able to catch it in GDB which confirms the error originates in LibCurl (backtraced).</p>
  
  <p>While I would love suggestions on the issue I am having, my actual question is this: Would it be better if I were to change the structure of my code to use the LibCurl Multi Interface on one thread instead of calling the single interface across multiple threads? What are the trade offs of using one over the other?</p>
  
  <p>Note: By "better", I mean is it faster and less taxing on my CPU? Is it more reliable as the multi interface was designed for this?</p>
  
  <p>EDIT:</p>
  
  <p>The three options I have as I understand it are these:</p>
  
  <p>1) Reuse the same easy_handle in a single thread. The connections wont need to be reestablished making it faster.</p>
  
  <p>2) Call curl_easy_perform() in each individual thread. They all run in parallel, again, making it faster.</p>
  
  <p>3) Call curl_multi_perform() in a single thread. This is non-blocking so I imagine all of the files are downloaded in parallel making it faster?</p>
  
  <p>Which of these options is the most time efficient?</p>