------- Comment #5 from sakovacs at freemail dot hu 2006-04-09 07:26 ------- Ok, please close this thread as non-bug/nothing to do, I still have an issue but I will raise it on the appropriate forum, it has nothing to do with GCC/libstdc++.
Just for the record: the problem roots in the malloc implementation, I think that it mmaps() memory for big memory chunks and uses a different algorithm for smaller ones. In the following program both good()/bad() allocates (around) max*29 bytes, after good() frees it the RSS goes down but not in the bad() case. #include <stdlib.h> #include <unistd.h> #include <string.h> int max = 10000000; // RSS doesn't shrink after this void bad() { char** p1 = (char**) calloc(max * sizeof(char*), 1); for (uint x = 0; x < max; x++) { p1[x] = (char*) calloc(29, 1); } for (uint x = 0; x < max; x++) { free(p1[x]); } free(p1); } // but RSS does shrink here void good() { char* p2 = (char*) calloc(max * 29, 1); // use calloc to make sure the memory was allocated, seems like malloc() delays the actual allocation free(p2); } int main(int argc, char *argv[]) { bad(); usleep(2000 * 1000); return 0; } Thanks for the help and sorry about bothering with this issue, Cheers, Sandor -- sakovacs at freemail dot hu changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27079