ff2e5ca85a15d099bda3faf3ab2aa6b96404c593 hiram Fri Feb 11 10:37:47 2011 -0800 adding printVmPeak() function to allow checking of maximum memory usage diff --git src/lib/obscure.c src/lib/obscure.c index 55d601b..4d907a2 100644 --- src/lib/obscure.c +++ src/lib/obscure.c @@ -675,15 +675,39 @@ } } void spaceToUnderbar(char *s) /* Convert white space to underbar. */ { char c; while ((c = *s) != 0) { if (isspace(c)) *s = '_'; ++s; } } +void printVmPeak() +/* print to stderr peak Vm memory usage (if /proc/ business exists) */ +{ +pid_t pid = getpid(); +char temp[256]; +safef(temp, sizeof(temp), "/proc/%d/status", (int) pid); +struct lineFile *lf = lineFileMayOpen(temp, TRUE); +if (lf) + { + char *line; + while (lineFileNextReal(lf, &line)) + { + if (stringIn("VmPeak", line)) + { + fprintf(stderr, "# pid=%d: %s\n", pid, line); + break; + } + } + lineFileClose(&lf); + } +else + fprintf(stderr, "# printVmPeak: %s - not available\n", temp); +fflush(stderr); +}