Skip to content

Instantly share code, notes, and snippets.

@hawkinsw
Created June 28, 2024 21:36
Show Gist options
  • Save hawkinsw/32a285bfd2389948ff195bf64b37343a to your computer and use it in GitHub Desktop.
Save hawkinsw/32a285bfd2389948ff195bf64b37343a to your computer and use it in GitHub Desktop.
Does Windows "Over" Allocate?
#include <iostream>
#include <fstream>
#include <malloc.h>
#include <cassert>
int main() {
std::ofstream output{ "results-release.csv" };
uint64_t max_alloc_request_size = 16*1024;
uint64_t alloc_request_size = 0;
for (; alloc_request_size < max_alloc_request_size; alloc_request_size++) {
void* leaked = malloc(alloc_request_size);
assert(leaked != NULL);
auto alloc_actual_size = _msize(leaked);
output << alloc_request_size << ", " << alloc_actual_size << "\n";
free(leaked);
}
output.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment