/**
* Memleak leaks memory at the specified rate
* Copyright (C) 2022 Aaron Ball, nullspoon@oper.io
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include
#include
#include
#include
char* BUF;
void handler(int sig) {
printf("\nAwwwww. So close.\n");
free(BUF);
exit(128);
}
int main(int argc, char* argv[]) {
long rate = 0;
long i=1;
signal(SIGINT, handler);
if(argc == 1) {
printf("Please specify a leak rate in MBs per second.\n");
return 1;
}
rate = strtol(argv[1], NULL, 10) * 1024 * 1024;
BUF = malloc(i);
while(1) {
printf("Reallocating %ld MB\n", i / 1024 / 1024);
BUF = realloc(BUF, i);
memset(BUF, 1, i);
usleep(100000);
i += rate;
}
}