Created
June 8, 2018 08:59
-
-
Save ethercflow/15431b3efd2523312eedb3a7c28744a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <string.h> | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #define BLOCKSIZE 1048576 | |
| #define N 200 | |
| #define BUSYTIME 1000 | |
| int main(int argc, char *argv[]) { | |
| int **p = malloc(N * sizeof(int*));; | |
| int i; | |
| while (1) { | |
| for (i = 0; i < N; i++) { | |
| p[i] = malloc(BLOCKSIZE); | |
| memset(p[i],'\0',BLOCKSIZE); | |
| usleep(BUSYTIME); | |
| } | |
| fprintf(stderr, "malloced\n"); | |
| for (i = 0; i < N; i++) { | |
| free(p[i]); | |
| usleep(BUSYTIME); | |
| } | |
| fprintf(stderr, "freed\n"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| i=0 | |
| while ((i<22)); do | |
| nohup ./mem & | |
| let ++i | |
| echo $i | |
| sleep 1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment