Skip to content

curl_multi_add_handle() returning OOM when using more than 400 handles #17473

Closed
@jeroen

Description

@jeroen

After upgrading to curl 8.14 we see "Out of memory" errors when adding handles to a multi. This was not the case before, and I am quite sure the system is not out of memory.

#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(void) {
  curl_global_init(CURL_GLOBAL_DEFAULT);
  CURLM *multi_handle = curl_multi_init();
  for(int i = 0; i < 1000; i++){
    CURL *http_handle = curl_easy_init();
    int res = curl_easy_setopt(http_handle, CURLOPT_URL, "https://www.example.com/");
    if(res != CURLE_OK){
      printf("ERROR: %s\n", curl_easy_strerror(res));
    }
    int res2 = curl_multi_add_handle(multi_handle, http_handle);
    if(res2 != CURLM_OK){
      printf("ERROR: %s\n", curl_multi_strerror(res2));
    }
  }
  return 0;
}

curl/libcurl version

curl 8.14.0

operating system

MacOS 15 ARM64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions