git://git.onelab.eu
/
mom.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
321a9b0
)
Stops growing after reaching specified size and waits..
author
Faiyaz Ahmed
<faiyaza@cs.princeton.edu>
Tue, 25 Jul 2006 18:09:19 +0000
(18:09 +0000)
committer
Faiyaz Ahmed
<faiyaza@cs.princeton.edu>
Tue, 25 Jul 2006 18:09:19 +0000
(18:09 +0000)
leak.c
patch
|
blob
|
history
diff --git
a/leak.c
b/leak.c
index
271d41b
..
dfd6fa5
100644
(file)
--- a/
leak.c
+++ b/
leak.c
@@
-4,7
+4,7
@@
* Mark Huang <mlhuang@cs.princeton.edu>
* Copyright (C) 2006 The Trustees of Princeton University
*
* Mark Huang <mlhuang@cs.princeton.edu>
* Copyright (C) 2006 The Trustees of Princeton University
*
- * $Id$
+ * $Id
: leak.c,v 1.1 2006/05/01 18:28:22 mlhuang Exp
$
*/
#include <stdio.h>
*/
#include <stdio.h>
@@
-16,17
+16,19
@@
int
main(int argc, char *argv[])
{
int rate = 16;
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' },
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 }
};
{ "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;
if (c == -1)
break;
@@
-34,10
+36,14
@@
main(int argc, char *argv[])
case 'r':
rate = atoi(optarg);
break;
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");
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;
}
}
return 0;
}
}
@@
-46,7
+52,7
@@
main(int argc, char *argv[])
for (;;) {
int i, bufsize = rate * 1024 * 1024;
char *buf = malloc(bufsize);
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;
/* Touch every page in the buffer */
for (i = 0; i < bufsize; i += 4096)
buf[i] = 1;