Streaming::setModelAsNoLongerNeeded

From RAGE Multiplayer Wiki

Client-Side
Function

 JavaScript



JavaScript Syntax


Function

This function releases a specified model from memory. It’s helpful for optimizing memory usage, especially after spawning an entity using a model. After calling this, the game will no longer store the model in memory, freeing up resources.

Syntax

mp.game.streaming.setModelAsNoLongerNeeded(model);

Required Arguments

  • model: Model hash or name

Return value

  • Undefined

Example

// Load a model and create a ped, then release the model from memory
let model = mp.game.joaat("a_m_y_skater_01");

if (!mp.game.streaming.hasModelLoaded(model)) {
    mp.game.streaming.requestModel(model);
    while (!mp.game.streaming.hasModelLoaded(model)) mp.game.wait(0); // Wait until model is loaded
}

// Create a ped using the model
let playerPed = mp.peds.new(model, new mp.Vector3(0, 0, 0), 0);

// Release the model from memory after creating the ped
mp.game.streaming.setModelAsNoLongerNeeded(model);



See also