2013-04-16 23:57:27 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2013-04-16 23:58:56 -04:00
|
|
|
#include <toku_assert.h>
|
2013-04-16 23:57:27 -04:00
|
|
|
#include <string.h>
|
2013-04-16 23:57:54 -04:00
|
|
|
#include <toku_stdint.h>
|
2013-04-16 23:57:28 -04:00
|
|
|
#include <toku_os.h>
|
2013-04-16 23:57:27 -04:00
|
|
|
|
2013-04-16 23:57:43 -04:00
|
|
|
const int nbuffers = 1000;
|
|
|
|
const int buffersize = 1024*1024;
|
|
|
|
|
2013-04-16 23:57:27 -04:00
|
|
|
static void do_mallocs(void) {
|
|
|
|
int i;
|
2013-04-16 23:57:43 -04:00
|
|
|
void *vp[nbuffers];
|
2013-04-16 23:57:43 -04:00
|
|
|
for (i=0; i<nbuffers; i++) {
|
|
|
|
int nbytes = buffersize;
|
2013-04-16 23:57:43 -04:00
|
|
|
vp[i] = malloc(nbytes);
|
|
|
|
memset(vp[i], 0, nbytes);
|
2013-04-16 23:57:27 -04:00
|
|
|
}
|
2013-04-16 23:57:43 -04:00
|
|
|
for (i=0; i<nbuffers; i++)
|
|
|
|
free(vp[i]);
|
2013-04-16 23:57:27 -04:00
|
|
|
}
|
|
|
|
|
2013-04-16 23:57:43 -04:00
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
int verbose = 0;
|
|
|
|
int i;
|
|
|
|
for (i=1; i<argc; i++) {
|
|
|
|
if (strcmp(argv[i], "-v") == 0) {
|
|
|
|
verbose = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (strcmp(argv[i], "-q") == 0) {
|
|
|
|
verbose = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2013-04-16 23:57:27 -04:00
|
|
|
|
2013-04-16 23:57:43 -04:00
|
|
|
int64_t rss;
|
2013-04-16 23:57:28 -04:00
|
|
|
toku_os_get_max_rss(&rss);
|
2013-04-16 23:57:43 -04:00
|
|
|
if (verbose) printf("%"PRId64"\n", rss);
|
|
|
|
assert(rss < nbuffers*buffersize);
|
2013-04-16 23:57:27 -04:00
|
|
|
do_mallocs();
|
2013-04-16 23:57:28 -04:00
|
|
|
toku_os_get_max_rss(&rss);
|
2013-04-16 23:57:43 -04:00
|
|
|
if (verbose) printf("%"PRId64"\n", rss);
|
|
|
|
assert(rss > nbuffers*buffersize);
|
2013-04-16 23:57:27 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|