Skip to content

Instantly share code, notes, and snippets.

@janjongboom
Created January 18, 2017 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janjongboom/bbfb89c31db3cda135138b72a8093f64 to your computer and use it in GitHub Desktop.
Save janjongboom/bbfb89c31db3cda135138b72a8093f64 to your computer and use it in GitHub Desktop.
malloc
static void start_filling_up() {
void* buffer;
uint32_t allocated = 0;
uint32_t size = 4096;
while (true) {
if (size == 64) break;
buffer = malloc(size);
if (buffer == NULL) {
size = size / 2;
continue;
}
printf("Allocated %d bytes\n", size);
allocated += size;
wait_ms(10);
}
printf("Allocated %d bytes before failed\n", allocated);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment