X-Git-Url: http://git.onelab.eu/?p=mom.git;a=blobdiff_plain;f=leak.c;h=6439ed17fca203521e7266f212947b05dbe53af0;hp=271d41bba4399a7d7d58ed2162705132543b1595;hb=a7ab53cbaf3037b67fbda98fed3887c905d93e96;hpb=72f7c344fe26e33cbe48cbc1fe5c9b09fd019c5c diff --git a/leak.c b/leak.c index 271d41b..6439ed1 100644 --- a/leak.c +++ b/leak.c @@ -4,7 +4,6 @@ * Mark Huang * Copyright (C) 2006 The Trustees of Princeton University * - * $Id$ */ #include @@ -16,17 +15,19 @@ int main(int argc, char *argv[]) { int rate = 16; + int size = 1; int leaked; for (;;) { int c, option_index = 0; static struct option long_options[] = { { "rate", required_argument, NULL, 'r' }, + { "size", optional_argument, NULL, 's' }, { "help", no_argument, NULL, 'h' }, { 0, 0, 0, 0 } }; - c = getopt_long(argc, argv, "r:h", long_options, &option_index); + c = getopt_long(argc, argv, "r:h:s", long_options, &option_index); if (c == -1) break; @@ -34,10 +35,14 @@ main(int argc, char *argv[]) case 'r': rate = atoi(optarg); break; + case 's': + size = atoi(optarg); + break; case 'h': default: fprintf(stderr, "Usage: %s [OPTION]...\n", argv[0]); fprintf(stderr, "\t-r, --rate=MiB/sec\tRate to leak memory in MiB/sec\n"); + fprintf(stderr, "\t-s, --size=MiB\tGrow to size and wait.\n"); return 0; } } @@ -46,7 +51,7 @@ main(int argc, char *argv[]) for (;;) { int i, bufsize = rate * 1024 * 1024; char *buf = malloc(bufsize); - if (buf) { + if (buf && (leaked <= size)) { /* Touch every page in the buffer */ for (i = 0; i < bufsize; i += 4096) buf[i] = 1;