Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Allocate memory forever (mostly)
- // The OS should kill the process
- //
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- int main(int argc, char** argv) {
- const int mb_size = 50 ;
- char* buffer;
- while (1) {
- buffer=malloc(1024*1024*mb_size);
- mb++;
- if (buffer == NULL) {
- printf("Unable to allocate buffer");
- } else {
- memset(buffer, 0, 1024*1024*mb_size);
- }
- printf("Allocated %d MB\n", mb*mb_size);
- // Yield process so that UIs update and it can be interrupted
- usleep(50000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement