mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 09:19:58 -04:00
Cap the memory released textures keep for reuse, and free old ones when the system commit runs low.
After an hour at 2160p the 2048 released entries held 5-7 GiB of render targets and decoded textures, charged to Windows' commit as well. NX2NAVI_TEX_RELEASED_MB caps them by size (default 1/16 of RAM, 1-4 GiB), and with less commit free than NX2NAVI_TEX_COMMIT_FREE_MB they are dropped to 256 MiB. Only entries released 120 frames ago or more go, at most 32 a check, oldest first. On Linux the commit check applies only with vm.overcommit_memory = 2 (plat_commit_enforced). From a tester's fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1666,6 +1666,20 @@ void plat_commit_info(double *proc_mb, double *used_mb, double *limit_mb) {
|
||||
if (private_bytes) *proc_mb = (double)(private_bytes >> 20);
|
||||
}
|
||||
|
||||
int plat_commit_enforced(void) {
|
||||
static int v = -1; // read once
|
||||
if (v < 0) {
|
||||
int mode = 0;
|
||||
FILE *f = fopen("/proc/sys/vm/overcommit_memory", "r");
|
||||
if (f) {
|
||||
if (fscanf(f, "%d", &mode) != 1) mode = 0;
|
||||
fclose(f);
|
||||
}
|
||||
v = mode == 2;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
// ---- child processes
|
||||
|
||||
struct PlatChild {
|
||||
|
||||
@@ -420,6 +420,8 @@ void plat_mem_info(float *used_mb, float *total_mb, float *proc_mb);
|
||||
// Commit charge in MB: this process's private bytes, the system's commit in use and its limit (RAM plus page files).
|
||||
// An allocation fails when the system's reaches the limit, however much physical memory is free. -1 when unknown.
|
||||
void plat_commit_info(double *proc_mb, double *used_mb, double *limit_mb);
|
||||
// Whether an allocation fails at that limit: always on Windows; on Linux only with vm.overcommit_memory = 2.
|
||||
int plat_commit_enforced(void);
|
||||
// This process's memory in bytes: resident (the working set) and private (Windows: committed private bytes; Linux: the
|
||||
// resident anonymous pages). 0 when unknown.
|
||||
void plat_process_memory(uint64_t *resident, uint64_t *private_bytes);
|
||||
|
||||
@@ -1721,6 +1721,8 @@ void plat_commit_info(double *proc_mb, double *used_mb, double *limit_mb) {
|
||||
*proc_mb = (double)(pmc.PrivateUsage >> 20);
|
||||
}
|
||||
|
||||
int plat_commit_enforced(void) { return 1; }
|
||||
|
||||
void plat_process_memory(uint64_t *resident, uint64_t *private_bytes) {
|
||||
PROCESS_MEMORY_COUNTERS_EX pm = {.cb = sizeof pm};
|
||||
*resident = *private_bytes = 0;
|
||||
|
||||
Reference in New Issue
Block a user