VRAM Deallocation, Session Destruction, and Physical Unloading Encyclopedia
sequenceDiagram
participant E as Unreal Engine
participant SUB as LiteRtLmSubsystem
participant K as Kernel (DLL)
E->>SUB: 1. Deinitialize() / EndPlay()
SUB->>K: 2. Physically Terminate Pumping
SUB->>K: 3. UnloadModel()
K->>K: 4. Destroy WebGPU Buffers
K->>K: 5. Disconnect mmap handles
Note over SUB, K: VRAM fully returned to OS
K-->>SUB: 6. Acknowledge Cleanup
SUB->>SUB: 7. Destroy Singleton Instance
Call when an individual NPC is destroyed to reclaim specific KV slots.
// Call in Actor EndPlay
FLiteRtLmUnrealApi::ReleaseSession(this);
Call during level transitions to free GBs of VRAM.
// Force evacuate all AI resources
FLiteRtLmUnrealApi::UnloadModel();
AI VRAM is not managed by UE5's RHI. Failure to unload will starve the renderer, leading to massive FPS drops in non-AI segments.
Unloading also unbinds file handles. This ensures you can swap or delete model files in Windows without "File in Use" errors.