UEFI firmware clears freed memory, adding 20 seconds to boots with Limine

Both of my DGX Sparks (UEFI 5.36_0ACUM018 and 5.36_0ACUM027) appear to be built with EDK2’s clear-on-free debug property enabled: when a boot loader returns memory with FreePages(), the firmware overwrites every freed page with 0xAF, at about 6 GiB/s.

DGX OS doesn’t notice, because GRUB only allocates what it needs. Limine, which I use to boot Omarchy alongside DGX OS, claims all usable memory at startup and returns it before starting a UKI, so the screen stays black for about 20 seconds after the boot menu. A timed Limine build spent 20.15 s returning 124 GiB, 19.06 s of it in a single 117 GiB FreePages() call. After boot, about 94% of free RAM reads back as 0xAF, EDK2’s default PcdDebugClearMemoryValue, which DEBUG_CLEAR_MEMORY() writes when pages return to EfiConventionalMemory.

Is clearing freed memory intended in the production firmware? If it’s a debug setting left on (DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED in PcdDebugPropertyMask), turning it off would let other boot loaders start as quickly as DGX OS. Measurements are in the Limine issue: UEFI chainload spends 20 s in FreePages on the NVIDIA DGX Spark · Issue #673 · Limine-Bootloader/Limine · GitHub