Files
VIctory/apps/victory
T
d1dfbbd4dc xmem: keep the space below 4 GiB for the title's 32-bit memory (#1009)
* xmem: keep the space below 4 GiB for the title's 32-bit memory

XMemVirtualAlloc with the 32-bit address flag has to fit below 4 GiB, where
Windows also puts the host's own memory first (it allocates bottom up). With
a large pipeline cache read at startup, the driver's, heap and cache memory
left 22 MB there, in pieces of at most 14 MB, when Grand Theft Auto VI asked
for a 185 MB 32-bit placeholder; the request was refused
(ERROR_NOT_ENOUGH_MEMORY) and the title stopped at an assertion
(+0x19f4f58). The D3D12 debug layer's memory did the same.

`low_guards::install`, at the start of `run`, reserves the free space below
4 GiB but the lowest 256 MB (left to the host). A 32-bit request that finds
no room releases the smallest guard that fits it (else the largest) and
tries again, then guards what is still free of it.

Tested: the new test releases a guard, takes part of the hole and checks the
rest is guarded again. In the title (RTX 2080, a build with a large cache):
without this the startup failed 2 of 3 times; with it, 5 of 5 starts passed,
3.7 GB below 4 GiB kept for the title.

* Bound low-address allocation retries to existing guards

* xmem: safety comments and formatting for the bounded guard retry

---------

Co-authored-by: swarm <swarm@swarm.swarm>
Co-authored-by: NuraadGit <NuraadGit@users.noreply.github.com>
d1dfbbd4dc · 2026-11-25 22:49:37 +01:00
History
..