How Linux allocates memory for malloc in a program
Hi,
I am new to Linux. I am allocating memory using malloc in a C program.
****************************
int *ptr;
if((ptr = malloc(sizeof(int)*1024*2000)) == NULL)
{
fprintf(stdout, "Malloc failed\n");
}
while(1)
{
//To make program running continuosly
}
******************************
When I check the memory being used by the system for this process using top command, it shows 308KB(RSS).
Could someone help me, why the difference occured in the memory allocated in the program using malloc and the memory allocated by the System.
I want to know how Linux allocates memory for a process.
Please help ASAP. Thanks in advance.
|