Created
March 8, 2022 10:07
-
-
Save no-defun-allowed/24c89a26c92790b18ecdbd018f12f665 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <gc.h> | |
#include <cstddef> | |
#include <new> | |
void* operator new(std::size_t n) { | |
void *p = GC_MALLOC(n); | |
if (!p) throw std::bad_alloc(); | |
return p; | |
} | |
void operator delete(void *p) { | |
(void)p; // lol | |
} | |
/* example use */ | |
#include <iostream> | |
int main() { | |
for (int i = 0; i < 1000000; i++) | |
char* x = new char[10000]; | |
std::cout << "lmao" << std::endl; | |
} | |
/* | |
[hayley@I-AM-NOT-A-BURNING-BUILDING tmp]$ g++ -lgc böhm.cpp -o böhm | |
[hayley@I-AM-NOT-A-BURNING-BUILDING tmp]$ /usr/bin/time ./böhm | |
lmao | |
13.10user 24.06system 0:11.97elapsed 310%CPU (0avgtext+0avgdata 4396maxresident)k | |
0inputs+0outputs (0major+296minor)pagefaults 0swaps | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment