dev.c skipped
This commit is contained in:
Meisam Bahadori 2026-07-22 15:18:09 +02:00 committed by Holger Vogt
parent 6acf1250d8
commit f81e775467
1 changed files with 20 additions and 7 deletions

View File

@ -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 */