parent
6acf1250d8
commit
f81e775467
|
|
@ -117,6 +117,14 @@ void ft_ckspace(void)
|
||||||
The caller then has to take care of memory available */
|
The caller then has to take care of memory available */
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
|
/* warn once per excursion above the threshold, not on every check */
|
||||||
|
static bool warned = false;
|
||||||
|
|
||||||
|
/* the same opt-out the outitf.c output-size estimate honors */
|
||||||
|
if (cp_getvar("no_mem_check", CP_BOOL, NULL, 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const unsigned long long freemem = getAvailableMemorySize();
|
const unsigned long long freemem = getAvailableMemorySize();
|
||||||
const unsigned long long usage = getCurrentRSS();
|
const unsigned long long usage = getCurrentRSS();
|
||||||
|
|
||||||
|
|
@ -126,13 +134,18 @@ void ft_ckspace(void)
|
||||||
|
|
||||||
const unsigned long long avail = usage + freemem;
|
const unsigned long long avail = usage + freemem;
|
||||||
if ((double) usage > (double) avail * 0.95) {
|
if ((double) usage > (double) avail * 0.95) {
|
||||||
(void) fprintf(cp_err,
|
if (!warned) {
|
||||||
"Warning - approaching max data size: "
|
(void) fprintf(cp_err,
|
||||||
"current size = ");
|
"Warning - approaching max data size: "
|
||||||
fprintmem(cp_err, usage);
|
"current size = ");
|
||||||
(void) fprintf(cp_err, ", limit = ");
|
fprintmem(cp_err, usage);
|
||||||
fprintmem(cp_err, avail);
|
(void) fprintf(cp_err, ", limit = ");
|
||||||
(void) fprintf(cp_err, "\n");
|
fprintmem(cp_err, avail);
|
||||||
|
(void) fprintf(cp_err, "\n");
|
||||||
|
warned = true;
|
||||||
|
}
|
||||||
|
} else if ((double) usage < (double) avail * 0.90) {
|
||||||
|
warned = false; /* re-arm after dropping clearly below the threshold */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} /* end of function ft_chkspace */
|
} /* end of function ft_chkspace */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue