Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int *memory_area1 = malloc(819200000);
- int *memory_area2 = malloc(819200000);
- int *memory_area3 = malloc(819200000);
- int *p;
- int i, j = 0;
- for (i = 0; i < 200000; i++) {
- /* write per 4kB, 1024*4byte */
- memory_area1[j] = 1;
- j += 1024;
- }
- j = 0;
- printf("First 800MB allocated\n");
- sleep(10);
- for (i = 0; i < 200000; i++) {
- memory_area2[j] = 1;
- j += 1024;
- }
- j = 0;
- printf("Second 800MB allocated\n");
- sleep(10);
- for (i = 0; i < 200000; i++) {
- memory_area3[j] = 1;
- j += 1024;
- }
- printf("Third 800MB allocated\n");
- sleep(15);
- printf("Start to flush third area is flushing .. \n");
- free(memory_area3);
- printf("Flush is completed\n");
- printf("Start to read first area\n");
- sleep(15);
- for (i = 0; i < 204800000; i++) {
- *p = *memory_area1;
- memory_area1++;
- }
- printf("Read is completed\n");
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment