Skip to content

Instantly share code, notes, and snippets.

@funny-falcon
Created January 11, 2012 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funny-falcon/1593514 to your computer and use it in GitHub Desktop.
Save funny-falcon/1593514 to your computer and use it in GitHub Desktop.
Test malloc allocation steps

Test of malloc allocation strategy.

Environment: Ubuntu 11.04 32bit. libc - libc6 (2.13ubuntu) tcmalloc - libtcmalloc_minimal0 1.5-1 jemalloc - jemalloc 2.2.5 standalone

tested allocation of 1000000 chunks with time -f %M chunk sizes are from 1 to 600. Only allocation strategy boundaries are shown.

libc jemalloc tcmalloc
1 - 79120
12 - 79120
13 - 110784
20 - 110784
21 - 141424
28 - 141424
29 - 173104
36 - 173104
37 - 203712
44 - 203712
45 - 235408
52 - 235408
53 - 267072
60 - 267072
61 - 297712
1 - 33568
4 - 33568
5 - 49408
8 - 49408
9 - 81040
16 - 81040
17 - 143584
32 - 143584
33 - 208704
48 - 208704
49 - 272000
64 - 272000
65 - 338448
1 - 51664
8 - 51664
9 - 83104
16 - 83104
17 - 145984
32 - 145984
33 - 209600
48 - 209600
49 - 271728
64 - 271728
65 - 335840
68 - 297712
69 - 329392
76 - 329392
77 - 360016
84 - 360016
85 - 391696
92 - 391696
93 - 423376
100 - 423376
101 - 453984
108 - 453984
109 - 485680
116 - 485680
117 - 516288
124 - 516288
125 - 547968
132 - 547968
133 - 578608
80 - 338448
81 - 399648
96 - 399648
97 - 462960
112 - 462960
113 - 527312
128 - 527312
129 - 781536
80 - 335840
81 - 403488
96 - 403488
97 - 467840
112 - 467840
113 - 523744
128 - 523744
129 - 610960
140 - 578608
141 - 610288
148 - 610288
149 - 641968
156 - 641968
157 - 672576
164 - 672576
165 - 704256
172 - 704256
173 - 734896
180 - 734896
181 - 766576
188 - 766576
189 - 798256
196 - 798256
197 - 828880
204 - 828880
205 - 860544
212 - 860544
213 - 891168
220 - 891168
221 - 922864
228 - 922864
229 - 954528
236 - 954528
237 - 985168
244 - 985168
245 - 1016832
252 - 1016832
253 - 1047456
260 - 1047456
261 - 1079152
192 - 781536
193 - 1036096
256 - 1036096
257 - 1291104
144 - 610960
145 - 679936
160 - 679936
161 - 735920
176 - 735920
177 - 802608
192 - 802608
193 - 883264
208 - 883264
209 - 930320
224 - 930320
225 - 982912
240 - 982912
241 - 1042096
256 - 1042096
257 - 1185808
268 - 1079152
269 - 1110816
276 - 1110816
277 - 1141456
284 - 1141456
285 - 1173120
292 - 1173120
293 - 1203760
300 - 1203760
301 - 1235424
308 - 1235424
309 - 1267120
316 - 1267120
317 - 1297744
324 - 1297744
325 - 1329424
332 - 1329424
333 - 1360032
340 - 1360032
341 - 1391712
348 - 1391712
349 - 1422352
356 - 1422352
357 - 1454032
364 - 1454032
365 - 1485696
372 - 1485696
373 - 1516336
380 - 1516336
381 - 1548016
396 - 1548016
397 - 1610304
412 - 1610304
413 - 1672608
428 - 1672608
429 - 1734928
444 - 1734928
445 - 1798288
460 - 1798288
461 - 1860592
476 - 1860592
477 - 1922896
492 - 1922896
493 - 1985200
508 - 1985184
509 - 2047504
524 - 2047504
525 - 2109440
540 - 2109440
541 - 2170880
556 - 2170880
557 - 2232320
572 - 2232320
573 - 2293760
588 - 2293760
589 - 2359296
320 - 1291104
321 - 1545552
384 - 1545552
385 - 1800624
448 - 1800624
449 - 2055008
512 - 2055008
513 - 3088384
288 - 1185808
289 - 1377424
320 - 1377424
321 - 1499360
352 - 1499360
353 - 1645696
384 - 1645696
385 - 1824544
448 - 1824544
449 - 2048080
512 - 2048080
513 - 2334720
576 - 2334720
577 - 2715648
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char **argv)
{
int count = atoi(argv[1]);
int size = atoi(argv[2]);
char **holder = (char**) malloc(sizeof(char*) * count);
int i;
for(i=0; i<count;i++) {
holder[i] = (char*) malloc(sizeof(char) * size);
memset(holder[i], 1, size * sizeof(char));
}
usleep(200000);
for(i=0; i<count;i++)
free(holder[i]);
free(holder);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment