EN 中文
Back to Overview

LiteRtLm_DestroyEngine

Engine destructor. Thoroughly releases GPU buffers, model weight memory, and associated thread pools. Ensures no memory dead zones are left behind.

01. Cascading Destruction Sequence

graph TD Engine[Engine Handle] -->|Destroy| ConvA[Conversation A] Engine -->|Destroy| ConvB[Conversation B] subgraph Resource_Free [Resource Recovery] VRAM[Release Model VRAM Weights] KV[Destroy Global KV Cache Pool] Thread[Terminate Inference Threads] end Engine --> Resource_Free
Handle Invalidation Warning: Once DestroyEngine is called, all session pointers (conv_ptr) created from this engine will become dangling pointers. All ongoing inference tasks must be stopped before calling this function.

02. Parameter Definition

void LiteRtLm_DestroyEngine(void* engine_ptr);
ParameterDescription
engine_ptr The engine handle to destroy. After invocation, this pointer is no longer usable.

03. Resource Recovery Recommendations

In Unreal Engine, it is recommended to call this interface during the EndPlay or BeginDestroy phase. Since it involves mandatory synchronous recovery of GPU resources, execution on a non-game thread is advised.

// UE5 Subsystem Cleanup Example
void UMyAiSubsystem::Deinitialize() {
    if (EngineHandle) {
        LiteRtLm_DestroyEngine(EngineHandle);
        EngineHandle = nullptr;
    }
    Super::Deinitialize();
}