/* * 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 #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; }