This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
malloc pb
- To: gcc-help at gcc dot gnu dot org
- Subject: malloc pb
- From: Yann Collete <collette at clt13bi dot der dot edf dot fr>
- Date: Thu, 12 Jul 2001 10:08:42 +0200 (MET DST)
Hello,
I've a little problem with malloc (maybe a bug).
I wrote the little following program:
#include <stdlib.h>
#include <time.h>
int main()
{
char * PtrChar;
time_t tstart, tend;
PtrChar = (char *)malloc(1000000*sizeof(char));
time(&tstart);
while(difftime(time(&tend), tstart) < 60) ;
free(PtrChar);
PtrChar = (char *)malloc(10000*sizeof(char));
time(&tsart);
while(difftime(time(&tend), tstart) < 60) ;
free(PtrChar);
}
I use the "top" program to follow the evolution of the memory
(the SHARE, RSS and SIZE label).
For the first malloc, I've SIZE=RSS=296ko and SHARE=240ko.
For the second malloc, I've SIZE=RSS=300ko and SHARE=240ko.
The memory doesn't seems to decrease between to two mallocs.
Why does it behave like this ?
the man page of top doesn't indicate that SIZE, RSS, SHARE measure
the max of the memory during the whole time of the process.
Yann COLLETTE