# UE5 BuildCookRun consumes all available memory and crashes

**URL:** <https://forums.unrealengine.com/t/ue5-buildcookrun-consumes-all-available-memory-and-crashes/1699995>\
**Category:** Platform & Builds\
**Tags:** build, unreal-engine, memory, cook, editor, question\
**Created:** [February 19, 2024, 4:54pm UTC](https://forums.unrealengine.com/t/ue5-buildcookrun-consumes-all-available-memory-and-crashes/1699995 "2024-02-19T16:54:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_jrdmellow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/_jrdmellow/32/912754_2.png) [@\_jrdmellow](https://forums.unrealengine.com/u/_jrdmellow)\
**Post date:** [February 19, 2024, 4:54pm UTC](https://forums.unrealengine.com/t/ue5-buildcookrun-consumes-all-available-memory-and-crashes/1699995/1 "2024-02-19T16:54:36Z")

</div>

I’m working on upgrading an existing UE4 production to UE5 (5.3.2). Everything has gone well so far as getting the engine and game up and running for our daily users, but I’m now trying to get our build machines updated too.

This is where I’m running into memory issues on our build agent. A few minutes into `BuildCookRun`, the `UnrealEditor` process has consumed a significant amount of memory, along with several `ShaderCompileWorkers`, and eventually runs out and crashes. The machine is a cloud-hosted dedicated VPS with 32 GB of RAM.

For context, running `BuildCookRun` on the UE4 build tops out around 24 GB. Here’s the (anonymized) command I’m running via a Powershell build step on the build machine;

```auto
./RunUAT.bat BuildCookRun `
    -nop4 -buildmachine `
    -project="<FullPathToGame>/Game.uproject" `
    -platform=Win64 `
    -clientconfig=Shipping `
    -build -cook `
    -archive -archivedirectory=Archive `
    -stage -pak -prereq -compressed

```

(similar to the one described in [this talk](https://youtu.be/q8igPUY_djc?si=S7lTlCCTM0SdOckP&t=529))

I’ve tried adjusting `MemoryMinFreePhysical` / `MemoryMinFreeVirtual` in `DefaultEditor.ini` under `CookSettings` to reserve a larger buffer of free memory.

I set it as high as 16 GB at one point to test and while it did seem to garbage collect more often in the logs, it still eventually crashed on OOM.

I also tried to limit `MemoryMaxUsedPhysical` and `MemoryMaxUsedVirtual` to all the way down 16 GB. This had practically identical results.

Finally, I’ve also tested all of this on my local machine, which has 64 GB of RAM. I am able to complete the cook on this machine, but it uses almost all of the available memory to do so, coming withing a few GB of running out of memory.

Has anyone run into similar issues? Any luck working around it?
