MTA:Eir/functions/engineStreamingIsGCOnDemandEnabled: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ This function returns whether a Streaming garbage collector run is performed to free required Streaming GC nodes for allocation...")
 
(Renamed template)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{MTA:Eir/Client_function}}
__NOTOC__  
__NOTOC__  
This function returns whether a [[GTA:SA_Streaming_Garbage_Collection|Streaming garbage collector]] run is performed to free required Streaming GC nodes for allocation by certain types of entities. Objects, buildings and dummies require Streaming GC nodes so the overall '''Streaming memory''' does not grow too high. They are the ones using most of the game memory.
This function returns whether a [[GTA:SA_Streaming_Garbage_Collection|Streaming garbage collector]] run is performed to free required Streaming GC nodes for allocation by certain types of entities. Objects, buildings and dummies require Streaming GC nodes so the overall '''Streaming memory''' does not grow too high. They are the ones using most of the game memory.

Latest revision as of 08:16, 28 September 2023

This function returns whether a Streaming garbage collector run is performed to free required Streaming GC nodes for allocation by certain types of entities. Objects, buildings and dummies require Streaming GC nodes so the overall Streaming memory does not grow too high. They are the ones using most of the game memory.

By default, Streaming GC on demand is disabled.

Syntax

bool engineStreamingIsGCOnDemandEnabled ()

Returns

Returns true if a Streaming garbage collector run is performed on node shortage, false otherwise.

Example

Click to collapse [-]
Client

This snippet enables infinite Streaming node allocation after two seconds of node shortage.

local firstNodeShortageTime = false;
local nodeShortageDuration = 2000;

local function isNodeShortage()
    return engineGetActiveStreamingFreeSlotCount() == 0;
end

local function enableStrictlessNodeAllocation( enabled )
    engineSetInfiniteStreamingEnabled( enabled );
    engineSetStrictNodeDistributionEnabled( not enabled );
    return true;
end

addEventHandler( "onClientPreRender", root,
    function()
        local isShortage = isNodeShortage();

        if ( isShortage ) then
            local now = getTickCount();

            if not ( firstNodeShortageTime ) then
                firstNodeShortageTime = now;
            elseif ( now - firstNodeShortageTime > nodeShortageDuration ) then
                engineStrictlessNodeAllocation( true );
            end
        else
            firstNodeShortageTime = false;
        end
    end
);