fix(libkernel): state the size of a direct memory backing Windows cannot create
On Windows each direct memory allocation is backed by a page-file section that CreateFileMappingW commits in full. When the system commit limit cannot cover it, the title stopped with "create direct memory backing: Insufficient system resources exist to complete the requested service", which did not say how much was requested. The error now states the requested size in bytes and MiB, and the runtime layout notes in USAGE.md describe the commit requirement and the page file. Allocation behaviour is unchanged: committing at allocation matches the console, where allocated direct memory is always backed by physical memory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e248f404ef
commit
62c70fb1d5
|
|
@ -226,7 +226,12 @@ public:
|
|||
#ifdef _WIN32
|
||||
const auto size = static_cast<std::uint64_t>(bytes);
|
||||
section = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_EXECUTE_READWRITE, static_cast<DWORD>(size >> 32), static_cast<DWORD>(size), nullptr);
|
||||
if (!section) throw std::system_error(static_cast<int>(GetLastError()), std::system_category(), "create direct memory backing");
|
||||
if (!section) {
|
||||
const auto error = static_cast<int>(GetLastError());
|
||||
char message[96];
|
||||
std::snprintf(message, sizeof(message), "create direct memory backing of 0x%llx bytes (%llu MiB)", static_cast<unsigned long long>(size), static_cast<unsigned long long>((size + 0xFFFFF) >> 20));
|
||||
throw std::system_error(error, std::system_category(), message);
|
||||
}
|
||||
#else
|
||||
file = memfd_create("direct memory", MFD_CLOEXEC);
|
||||
if (file < 0) throw std::system_error(errno, std::generic_category(), "create direct memory backing");
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ app0/
|
|||
|
||||
Use `sce_modules/` or `prx/` instead of `sce_module/` if that is the input directory name. Relinker preserves each module's directory under `app0/` and prints its exact path. Place app resources in `app0/` separately. Copy the built system libraries from `build/core/libs/libs/*.prx` into `libs/`; use libraries built for the target OS. A custom `--rpath` changes the system library location.
|
||||
|
||||
On Windows, direct memory (`sceKernelAllocateDirectMemory`, up to 13824 MiB per title) is committed in full when the title allocates it, not when its pages are first used. The system commit limit (installed memory plus page file size, the second value of Committed in Task Manager) must cover it together with all other committed memory. Otherwise the allocation throws `create direct memory backing of 0x<n> bytes (<m> MiB)` with the Windows error; enlarge the page file or close other applications.
|
||||
|
||||
Linux:
|
||||
|
||||
```sh
|
||||
|
|
|
|||
Loading…
Reference in New Issue