Friday, August 7, 2009

a.out memory layout

RE: Difference between program memory, data memory, stack memory and heap memory?
kindly see the memory diagram for C programs

Low Memory
__________________________
CODE MEMORY | (CODE SEGMENT)
__________________________|
INITIALIZED MEMORY | Initialized adn unintiallized static and
------------------------------------------| global variables stored here
UNINTIALIZED MEMORY (BSS) | (DATA SEGMENT)
__________________________|
HEAP | Memory allocated with calloc and malloc
__________________________| stored here
||
/

/
____________||_____________
STACK(STACK SEGMENT) | Initialized and unintiallized automatic
__________________________| variables store here


High Memory

arrow indiacates the growth of memory address as the memory is filled

This diagram shows the use of the CS DS SS ES

with regards

Aravind Kumar Singh






RE: how to find the size of an integer without using t...
#define SIZEOF(X) ( (char *) (X+1) - (char *) (X) )


main()
{
int *x;
double *y;
printf("The Size of integer is d bytesn" SIZEOF(x));
printf("The Size of double is d bytesn" SIZEOF(y));
}

No comments:

Post a Comment