I recently had to create a memory leak to do some testing, here is a snippet of code that I used to create a leak. You can adjust malloc size to allocate more memory, or adjust the usleep to adjust how aggressive it is. the code below on a machine with 500M of memory would chew up about 1% memory a second. Enjoy!
#include <stdlib.h>
#include <unistd.h>int main(void) {
/* An infinite loop. */
while (1) {
/* Try to allocate some memory. */
malloc(8386080);
/* sleep for a bit so its not so aggressive */
usleep(10000);
}
return EXIT_SUCCESS;
}