Skip to content

Instantly share code, notes, and snippets.

@xremix
Created January 5, 2018 09:33
Show Gist options
  • Save xremix/a0f4c8262e252fb30bf5f777a7d84300 to your computer and use it in GitHub Desktop.
Save xremix/a0f4c8262e252fb30bf5f777a7d84300 to your computer and use it in GitHub Desktop.
MemBlower

Memblower

ATTENTION! This is just for testing purposes. The two files try different approaches to store endless data in the memory. This experiment shows how the computer behaves in edge cases.

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
long* p;
// for (int i = 0; i < 2; ++i)
for (int i = 0; i < 100000000000; ++i)
{
p = malloc(2048);
}
printf("End");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
int a;
printf("Please input an integer value: ");
scanf("%d", &a);
long* p[1010000];
// for (int i = 0; i < 2; ++i)
for (int i = 0; i < 1010000; ++i)
{
p[i] = malloc(1024*1000);
*p[i] = (*p[i]);
// printf("x");
}
printf("End");
printf("Please input an integer value: ");
scanf("%d", &a);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment