From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function returns a breakdown of the process memory usage. The reported numbers are always byte units and these numbers can be inaccurate.


table|nil getProcessMemoryStats ( )


Returns a table if successful, otherwise returns nil

Property Description
virtual total program size
resident resident set size (memory in physical space/ram, also known as working set)
shared size of resident shared memory (shared with other processes)
private size of resident private memory (only for this process)

Note: Resident set size should be roughly shared + private from the table.


This example will output the memory usage by the server process to the console every 5 minutes.

Click to collapse [-]
    local div = 1024^2

    local pmem = getProcessMemoryStats()

    if pmem then
        outputServerLog(("[SYS] %.2f MiB  rss:%.2f MiB  shr:%.2f MiB  prv:%.2f MiB"):format(
            pmem.virtual / div,
            pmem.resident / div,
            pmem.shared / div,
            pmem.private / div
end, 5 * 60000, 0)

See Also