Problem
The oversized -dbcache warning threshold has a sharp formula cliff when detected RAM crosses the cutoff used by the warning logic.
This was reported during review of #34641, where an earlier version could jump from the auto default at 4095 MiB RAM to 75% of RAM at 4096 MiB.
That made 1 MiB of extra detected RAM raise the warning threshold from about 511 MiB to 3072 MiB.
The surviving warning-only code has the same shape at a different boundary.
Below 2 GiB RAM the cap is DEFAULT_DB_CACHE (450 MiB), but at 2 GiB it switches to 75% of total RAM, so a tiny increase in detected RAM can suddenly raise the warning threshold from 450 MiB to about 1536 MiB.
<img width="1484" height="881" alt="Image" src="https://github.com/user-attachments/assets/b51d5d24-31b8-4a2a-8f70-e7536481f855" />
Fix
Base the warning on a reserved non-dbcache memory budget instead:
\text{warn if } \mathit{dbcache} > \max\left(\mathit{DEFAULT\_DB\_CACHE}, 0.75 \cdot \max(\text{total RAM} - \mathit{DBCACHE\_WARNING\_RESERVED\_RAM}, 0)\right)
DBCACHE_WARNING_RESERVED_RAM is 2 GiB, so the fixed DEFAULT_DB_CACHE cap remains the floor below that reserve and the warning threshold grows monotonically above it.
This keeps the warning conservative around low-memory boundaries and avoids treating a boundary-crossing 1 MiB RAM difference as a reason to allow a much larger explicit -dbcache.
Quick reference
| System RAM | Previous warning cap | New warning cap |
|---|---|---|
| 1 GiB | 450 MiB | 450 MiB |
| 2 GiB | 1536 MiB | 450 MiB |
| 3 GiB | 2304 MiB | 768 MiB |
| 4 GiB | 3072 MiB | 1536 MiB |
| 8 GiB | 6144 MiB | 4608 MiB |
| 16 GiB | 12288 MiB | 10752 MiB |
| 32 GiB | 24576 MiB | 23040 MiB |
On 32-bit builds, effective -dbcache values are still capped to 1024 MiB before the warning check, so thresholds above that cap are not reachable there.