EngineStreamingSetMemorySize: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0160|1.6.0|21946|Sets the maximum amount of [in bytes] that can be used for streaming}} {{Tip|To restore to the default value use engineStreamingRestoreMemorySize}} {{Important Note|**This function is meant for advanced users only, as it can lead to stability issues**. Using a very high value might result in more crashes, while using a value too low might lead to frequent pop-in [and due to the way MTA works micro-st...")
 
(Remove obsolete Requirements section)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{New feature/item|3.0160|1.6.0|21946|Sets the maximum amount of [in bytes] that can be used for streaming}}
{{New feature/item|3.0160|1.6.0|21874|Sets the maximum amount of RAM [in bytes] that can be used for streaming}}
{{Tip|To restore to the default value use [[engineStreamingRestoreMemorySize]]}}
{{Tip|The `showmemstat` command can be used to see this value in real-time [You might have to scroll down using PgDown on your keyboard]}}
{{Important Note|**This function is meant for advanced users only, as it can lead to stability issues**. Using a very high value might result in more crashes, while using a value too low might lead to frequent pop-in [and due to the way MTA works micro-stutter as well]}}
{{Tip|To restore to default value use [[engineStreamingRestoreMemorySize]]}}
{{Important Note|'''This function is meant for advanced users only, as it can lead to stability issues'''. Using a very high value might result in more crashes, while using a value too low might lead to frequent pop-in [and due to the way MTA works micro-stutter as well]}}
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
nil engineStreamingSetMemorySize( number sizeBytes )
nil engineStreamingSetMemorySize( int sizeBytes )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[EngineStreaming]]:setMemorySize|memorySize|engineStreamingGetMemorySize}}
{{OOP||[[EngineStreaming]]:setMemorySize|memorySize|engineStreamingGetMemorySize}}
Line 14: Line 15:


==Example==
==Example==
This example sets the memory size to 512 MB.
This example adds a command that can be used to change the streaming memory size, and display the previous value.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler("cap", function(_, sizeMB)
addCommandHandler("ssms", function(_, sizeMB)
     if tonumber(sizeMB) then
     if tonumber(sizeMB) then
         outputChatbox("The maximum streaming memory available has been changed from " .. math.floor(engineGetStreamingMemorySize() / 1024 / 1024) .. " MB to " .. sizeMB .. " MB")       
         outputChatbox("The maximum streaming memory available has been changed from " .. math.floor(engineGetStreamingMemorySize() / 1024 / 1024) .. " MB to " .. sizeMB .. " MB")       
Line 25: Line 26:
end, false, false)
end, false, false)
</syntaxhighlight>
</syntaxhighlight>
==Requirements==
{{Requirements|n/a|1.6.0-9.21946|}}


==See Also==
==See Also==
{{Engine functions}}
{{Engine functions}}

Latest revision as of 17:33, 7 November 2024

Sets the maximum amount of RAM [in bytes] that can be used for streaming

[[{{{image}}}|link=|]] Tip: The `showmemstat` command can be used to see this value in real-time [You might have to scroll down using PgDown on your keyboard]
[[{{{image}}}|link=|]] Tip: To restore to default value use engineStreamingRestoreMemorySize
[[{{{image}}}|link=|]] Important Note: This function is meant for advanced users only, as it can lead to stability issues. Using a very high value might result in more crashes, while using a value too low might lead to frequent pop-in [and due to the way MTA works micro-stutter as well]

Syntax

nil engineStreamingSetMemorySize( int sizeBytes )

OOP Syntax Help! I don't understand this!

Method: EngineStreaming:setMemorySize(...)
Variable: .memorySize
Counterpart: engineStreamingGetMemorySize


Required Arguments

  • sizeBytes : The maximum amount of RAM [in bytes] that can be used for streaming. Must be a positive non-zero number.

Example

This example adds a command that can be used to change the streaming memory size, and display the previous value.

addCommandHandler("ssms", function(_, sizeMB)
    if tonumber(sizeMB) then
        outputChatbox("The maximum streaming memory available has been changed from " .. math.floor(engineGetStreamingMemorySize() / 1024 / 1024) .. " MB to " .. sizeMB .. " MB")      
        engineStreamingSetMemorySize(tonumber(sizeMB) * 1024 * 1024) -- Convert MB to Bytes
    else
        outputChatbox("Please enter a numeric value!")
    end
end, false, false)

See Also