Skip to content

Instantly share code, notes, and snippets.

@ReidAtcheson
Created March 12, 2023 21:02
Show Gist options
  • Save ReidAtcheson/5c36a510376b918380823ffba18a0e1b to your computer and use it in GitHub Desktop.
Save ReidAtcheson/5c36a510376b918380823ffba18a0e1b to your computer and use it in GitHub Desktop.
why alloc
#include <memory_resource>
int main(int argc,char** argv){
void* buffer;
std::pmr::monotonic_buffer_resource resource(buffer,8,std::pmr::null_memory_resource());
// When Above commented out:
//
//valgrind ./a.out
//==68433== HEAP SUMMARY:
//==68433== in use at exit: 0 bytes in 0 blocks
//==68433== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
//
//
// When *not* commented out:
//==68511== HEAP SUMMARY:
//==68511== in use at exit: 0 bytes in 0 blocks
//==68511== total heap usage: 1 allocs, 1 frees, 72,704 bytes allocated
//
//
//Built with: g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment