From f81e7754672fd0d878c7684cefcf48301f2ba6c9 Mon Sep 17 00:00:00 2001 From: Meisam Bahadori Date: Wed, 22 Jul 2026 15:18:09 +0200 Subject: [PATCH] pa-81 dev.c skipped --- src/frontend/resource.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/frontend/resource.c b/src/frontend/resource.c index acec7db42..b075fdbe0 100644 --- a/src/frontend/resource.c +++ b/src/frontend/resource.c @@ -117,6 +117,14 @@ void ft_ckspace(void) The caller then has to take care of memory available */ return; #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 usage = getCurrentRSS(); @@ -126,13 +134,18 @@ void ft_ckspace(void) const unsigned long long avail = usage + freemem; if ((double) usage > (double) avail * 0.95) { - (void) fprintf(cp_err, - "Warning - approaching max data size: " - "current size = "); - fprintmem(cp_err, usage); - (void) fprintf(cp_err, ", limit = "); - fprintmem(cp_err, avail); - (void) fprintf(cp_err, "\n"); + if (!warned) { + (void) fprintf(cp_err, + "Warning - approaching max data size: " + "current size = "); + fprintmem(cp_err, usage); + (void) fprintf(cp_err, ", limit = "); + 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 } /* end of function ft_chkspace */