[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Malloc pb
From: |
Yann Collete |
Subject: |
Malloc pb |
Date: |
Fri, 13 Jul 2001 09:00:47 +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
- Malloc pb,
Yann Collete <=