Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <unistd.h>
- int main(int argc, char *argv[])
- {
- void *p;
- intptr_t i;
- if (argc != 2) {
- fprintf(stderr, "usage: %s <gigabytes>\n", *argv);
- return 1;
- }
- i = atol(argv[1]);
- /* allocate X GB */
- p = sbrk(i * 1024 * 1024 * 1024);
- if ((intptr_t)p == -1) {
- perror("sbrk");
- return 1;
- }
- /* sleep forever */
- pause();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement