|
From: Mark S. <ms...@cl...> - 2005-05-19 19:59:45
|
This C program:
#include <stdlib.h>
int main(int argc, char **argv)
{
char *data =3D NULL;
int len =3D 0;
for(int i=3D0; i<2000; i++) {
len +=3D 4096;
data =3D (char *) realloc(data, len*sizeof(char));
}
free(data);
return 0;
}
Seems to cause valgrind to allocate a *lot* of memory, at least 700MB. I
tested it on a fairly stock RH9 system with gcc 3.2.2 and a fairly stock
SuSE 9.1 system with gcc 3.3.3.
Any idea why it's so inefficent?
--Mark
|