mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 11:09:56 -04:00
Say in the log when the system's commit runs low under a page file that Windows sizes itself.
With the page file left to Windows the commit limit stays near the installed memory plus what the file held at the start, and on a 16 GB PC with a 16 GB card it ran low in Hyrule Field at 32 GB, where a fixed page file of 32 GB or more gave 49 GB and no low commit. The first "system commit low" line of a run is now followed, once, by a line that names the cause and the Windows setting, and the build kit's guide gives the same advice for 16 GB PCs. plat_page_file_managed reads the PagingFiles value once; on this PC (page file sized by Windows) it returns 1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -2229,6 +2229,9 @@ int plat_commit_note(char *out, size_t cap) {
|
||||
// The cgroup's memory.current and MemAvailable count system memory only: a graphics card's own memory is in neither.
|
||||
int plat_commit_counts_vram(void) { return 0; }
|
||||
|
||||
// Swap is not a page file Windows sizes; the limits plat_commit_info reads do not grow with it.
|
||||
int plat_page_file_managed(void) { return -1; }
|
||||
|
||||
// ---- child processes
|
||||
|
||||
struct PlatChild {
|
||||
|
||||
@@ -488,6 +488,9 @@ int plat_commit_note(char *out, size_t cap);
|
||||
// Whether a discrete GPU's own memory counts against that limit: on Windows the driver charges device memory to the
|
||||
// system's commit; Linux's limits count system memory only.
|
||||
int plat_commit_counts_vram(void);
|
||||
// Whether Windows sizes a page file by itself (System managed size): 1; 0 when every page file has a size set; -1
|
||||
// when unknown, there is none, or not Windows.
|
||||
int plat_page_file_managed(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);
|
||||
|
||||
@@ -1922,6 +1922,28 @@ int plat_commit_note(char *out, size_t cap) {
|
||||
// The driver charges the device memory it allocates to the system's commit.
|
||||
int plat_commit_counts_vram(void) { return 1; }
|
||||
|
||||
// The PagingFiles value under Memory Management, one "<path> <initial MB> <maximum MB>" per page file: a path of
|
||||
// "?:\..." (System managed size on every drive) or no sizes or "0 0" (System managed size on that drive) leaves the
|
||||
// size to Windows. Read once; the setting takes effect only after a restart.
|
||||
int plat_page_file_managed(void) {
|
||||
static int managed = -2;
|
||||
if (managed != -2) return managed;
|
||||
wchar_t v[2048];
|
||||
DWORD size = sizeof v - sizeof(wchar_t) * 2;
|
||||
int r = -1;
|
||||
if (RegGetValueW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management",
|
||||
L"PagingFiles", RRF_RT_REG_MULTI_SZ, NULL, v, &size) == ERROR_SUCCESS) {
|
||||
v[size / sizeof(wchar_t)] = v[size / sizeof(wchar_t) + 1] = 0;
|
||||
for (wchar_t *e = v; *e; e += wcslen(e) + 1) {
|
||||
wchar_t *sp = wcschr(e, L' ');
|
||||
unsigned long lo = sp ? wcstoul(sp, &sp, 10) : 0, hi = sp ? wcstoul(sp, NULL, 10) : 0;
|
||||
int own = e[0] == L'?' || (!lo && !hi);
|
||||
r = own ? 1 : r < 0 ? 0 : r;
|
||||
}
|
||||
}
|
||||
return managed = r;
|
||||
}
|
||||
|
||||
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