Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<unistd.h>
- #include<stdlib.h>
- #include<stdio.h>
- #define A_MEGABYTE (1024*1024)
- #define PHY_MEM_MEGS 1024
- int main()
- {
- char *s_mem;
- size_t size_to_allocate=A_MEGABYTE;
- int megs_obtained=0;
- while(megs_obtained<(PHY_MEM_MEGS*2))
- {
- s_mem=(char *)malloc(size_to_allocate);
- if(s_mem!=NULL)
- {
- megs_obtained++;
- sprintf(s_mem,"hello");
- printf("\n%s -now allocated %d mb",s_mem,megs_obtained);
- //sleep(1);
- }
- else
- {
- exit(EXIT_FAILURE);
- }
- }
- exit(EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement