diff options
author | Daniel Stenberg <daniel@haxx.se> | 2013-04-26 22:23:08 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2013-04-26 22:55:55 +0200 |
commit | 642067287931da64e485e402e5e1fa5096abcddd (patch) | |
tree | f1c843b46447d2e4607bfe029823352932c4d01f /lib/easy.c | |
parent | c4067a5678321b1755f6027a5c7510b17e7c16a6 (diff) | |
download | curl-642067287931da64e485e402e5e1fa5096abcddd.tar.gz |
curl_easy_init: use less mallocs
By introducing an internal alternative to curl_multi_init() that accepts
parameters to set the hash sizes, easy handles will now use tiny socket
and connection hash tables since it will only ever add a single easy
handle to that multi handle.
This decreased the number mallocs in test 40 (which is a rather simple
and typical easy interface use case) from 1142 to 138. The maximum
amount of memory allocated used went down from 118969 to 78805.
Diffstat (limited to 'lib/easy.c')
-rw-r--r-- | lib/easy.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/easy.c b/lib/easy.c index 72e1206f4..eb45bd717 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -73,6 +73,7 @@ #include "non-ascii.h" #include "warnless.h" #include "conncache.h" +#include "multiif.h" #define _MPRINTF_REPLACE /* use our functions only */ #include <curl/mprintf.h> @@ -437,7 +438,9 @@ CURLcode curl_easy_perform(CURL *easy) if(data->multi_easy) multi = data->multi_easy; else { - multi = curl_multi_init(); + /* this multi handle will only ever have a single easy handled attached + to it, so make it use minimal hashes */ + multi = Curl_multi_handle(1, 3); if(!multi) return CURLE_OUT_OF_MEMORY; data->multi_easy = multi; |