MCPcopy Create free account
hub / github.com/Niko1221/Strata / job_commit_room_bytes

Function job_commit_room_bytes

engine/include/strata/platform/commit.hpp:57–80  ·  view source on GitHub ↗

Queries the current Windows Job Object commit ceiling, or UINT64_MAX when unconstrained / off Windows.

Source from the content-addressed store, hash-verified

55
56/// Queries the current Windows Job Object commit ceiling, or UINT64_MAX when unconstrained / off Windows.
57inline uint64_t job_commit_room_bytes(uint64_t discrete_vram_reserve = 0) noexcept {
58#if defined(_WIN32)
59 BOOL in_job = FALSE;
60 if (!IsProcessInJob(GetCurrentProcess(), nullptr, &in_job) || !in_job) return UINT64_MAX;
61 JOBOBJECT_EXTENDED_LIMIT_INFORMATION ji{};
62 if (!QueryInformationJobObject(nullptr, JobObjectExtendedLimitInformation, &ji, sizeof(ji), nullptr)) {
63 return UINT64_MAX;
64 }
65 const DWORD flags = ji.BasicLimitInformation.LimitFlags;
66 const uint64_t proc_lim = (flags & JOB_OBJECT_LIMIT_PROCESS_MEMORY) ? (uint64_t) ji.ProcessMemoryLimit : 0;
67 const uint64_t job_lim = (flags & JOB_OBJECT_LIMIT_JOB_MEMORY) ? (uint64_t) ji.JobMemoryLimit : 0;
68 if (proc_lim == 0 && job_lim == 0) return UINT64_MAX;
69 PROCESS_MEMORY_COUNTERS_EX pmc{};
70 pmc.cb = sizeof(pmc);
71 const uint64_t proc_used = K32GetProcessMemoryInfo(GetCurrentProcess(),
72 reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&pmc), sizeof(pmc))
73 ? (uint64_t) pmc.PrivateUsage
74 : 0;
75 return job_commit_room_from_limits(proc_lim, proc_used, job_lim, proc_used, discrete_vram_reserve);
76#else
77 (void) discrete_vram_reserve;
78 return UINT64_MAX;
79#endif
80}
81
82/// #6748: the host memory an expert pool may take on Windows is what is free in RAM AND what can still be committed. Pinned and
83/// private allocations are charged to the commit limit (RAM plus page files), which can be smaller than the free RAM: 16.2 GiB of RAM

Callers 1

commit_availableFunction · 0.85

Calls 1

Tested by

no test coverage detected