mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-15 19:19:58 -04:00
The game held 23.9 to 24.4 GB of commit in three sessions on an RTX 5090 at 3840x2160, flat over the session, on a machine whose commit stood at 66 of 73 GB with it. A machine that cannot give it that much pages, drops textures or loses the device, and its log said nothing about memory until then. mem_start_note reads the system's commit when a game starts and writes one warning line when what is free, plus what the process already holds, is below mem_need_mb (24576 by default, 0 for no warning). The menu has no place for a start-up notice (its only toasts are the co-op page's), so the line is in the log alone. tests/mem_need_check.py checks the rule and, through --probe-memneed, the answer and the warning line with the machine's own commit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
43 lines
2.3 KiB
C
43 lines
2.3 KiB
C
// runtime/mem_need.h: whether the machine has the commit the game needs (runtime/memory.c mem_start_note). Built and
|
|
// run by tests/mem_need_check.py; prints each failed check and exits 1 on any.
|
|
#include <stdio.h>
|
|
|
|
#include "mem_need.h"
|
|
|
|
static int fails;
|
|
#define CHECK(c, ...) do { if (!(c)) { fails++; printf("FAIL line %d: ", __LINE__); printf(__VA_ARGS__); printf("\n"); } } while (0)
|
|
|
|
int main(void) {
|
|
const double need = MEM_NEED_DEFAULT_MB;
|
|
|
|
// The machine the need was measured on, before the game starts: 41,515 of 73,154 MB in use, the process at 369 MB.
|
|
// 32,008 MB for the game: enough.
|
|
CHECK(!mem_need_short(369, 41515, 73154, need), "short with 32 GB for the game");
|
|
CHECK(mem_need_room(369, 41515, 73154) == 73154 - 41515 + 369, "room %.0f", mem_need_room(369, 41515, 73154));
|
|
|
|
// The same machine with the game in play, 65,840 of 73,154 MB in use and 24,000 MB of them the game's: what the
|
|
// game holds counts toward its need, so a check made late does not call a fitting game short.
|
|
CHECK(!mem_need_short(24000, 65840, 73154, need), "short in play although the game's own commit fits");
|
|
|
|
// A 32 GB machine with an 8 GB page file and 12 GB in use by other programs: 28 GB free, enough; with 20 GB in
|
|
// use, 20 GB free: short.
|
|
CHECK(!mem_need_short(300, 12000, 40960, need), "short with 29 GB free");
|
|
CHECK(mem_need_short(300, 20000, 40960, need), "enough with 21 GB free");
|
|
|
|
// A 16 GB machine with a 4 GB page file never fits.
|
|
CHECK(mem_need_short(300, 6000, 20480, need), "enough on a 16 GB machine");
|
|
|
|
// The boundary: exactly the need is enough, one MB less is short.
|
|
CHECK(!mem_need_short(0, 1000, 1000 + need, need), "short with exactly the need free");
|
|
CHECK(mem_need_short(0, 1001, 1000 + need, need), "enough one MB below the need");
|
|
|
|
// Not asked (0), and a platform without a known limit (-1): never short. A process reading of -1 (unknown) adds
|
|
// nothing to the room.
|
|
CHECK(!mem_need_short(300, 20000, 20480, 0), "short with the check off");
|
|
CHECK(!mem_need_short(300, 20000, -1, need), "short without a known limit");
|
|
CHECK(mem_need_room(-1, 20000, 40960) == 20960, "an unknown process commit changed the room");
|
|
|
|
printf("mem_need_check: %s\n", fails ? "FAILED" : "passed");
|
|
return fails ? 1 : 0;
|
|
}
|