1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/ex1/ex1.4/leak_memory.cpp
Eric Teunis de Boone 4c31b5a287 Ex1: Copied Code from Intro CPP repo:
git@git.deboone.nl:ericteunis/documenten/uni/m.cpp.git
2019-11-12 10:49:02 +01:00

26 lines
523 B
C++

/*
* Deliberately leak memory
*
* Free memory decreases for a second.
* However, because the program quits, the kernel frees the used memory
*
* If run for some time, my swap space would fill, afterwards my computer is brought to a halt.
*
*/
#include <iostream>
#define K 1000
#define M K*K
#define G K*M
#define MEMORY_SIZE_IN_CHARS G
int main() {
char* throwaway_ptr = new char[MEMORY_SIZE_IN_CHARS];
std::cout << "We leaked " << MEMORY_SIZE_IN_CHARS * sizeof " " << " bits" << std::endl;
return 0;
}