VRAM Force-Reclaim, mmap Handle Closure, and Shutdown Protocols
sequenceDiagram
participant E as Unreal Engine
participant SUB as Subsystem
participant K as Kernel (DLL)
E->>SUB: 1. Deinitialize() / EndPlay()
SUB->>K: 2. Physically Terminate Task Pumping
SUB->>K: 3. UnloadModel()
K->>K: 4. Destroy WebGPU Buffers
K->>K: 5. Force Disconnect mmap handles
Note over SUB, K: VRAM fully returned to OS
K-->>SUB: 6. Confirm Resources Null
SUB->>SUB: 7. Destroy Singleton Instance
Reclaim specific VRAM slots when an individual agent is destroyed.
// Call in Agent's EndPlay
Subsystem->ReleaseSession(this);
Mandatory for level transitions to release GBs of locked VRAM.
// Force evacuate all kernel resources
FLiteRtLmUnrealApi::UnloadModel();
AI VRAM is not managed by UE5. Failure to unload will result in physical locking of GBs of memory even after exiting PIE, starving subsequent rendering tasks.
Without UnloadModel, Windows OS will continue to lock the .bin file, preventing you from replacing or deleting the model weights on disk.