gleam/os_mon/mem

Types

pub type Errors {
  ValueTooSmall(Int)
  ValueTooLarge(Int)
  Crash(erlang.Crash)
}

Constructors

  • ValueTooSmall(Int)
  • ValueTooLarge(Int)
  • Crash(erlang.Crash)
pub type Memory {
  Memory(
    available: Int,
    buffered: Int,
    cached: Int,
    free: Int,
    swap_free: Int,
    swap_total: Int,
    system_total: Int,
    total: Int,
  )
}

Constructors

  • Memory(
      available: Int,
      buffered: Int,
      cached: Int,
      free: Int,
      swap_free: Int,
      swap_total: Int,
      system_total: Int,
      total: Int,
    )

    All memory sizes are presented as number of bytes.

    Arguments

    • available

      Informs about the amount memory that is available for increased usage if there is an increased memory need. This value is not based on a calculation of the other provided values and should give a better value of the amount of memory that actually is available than calculating a value based on the other values reported.

    • buffered

      The amount of memory the system uses for temporary storing raw disk blocks.

    • cached

      The amount of memory the system uses for cached files read from disk. On Linux, also memory marked as reclaimable in the kernel slab allocator will be added to this value.

    • free

      The amount of free memory available to the Erlang emulator for allocation.

    • swap_free

      The amount of memory the system has available for disk swap.

    • swap_total

      The amount of total amount of memory the system has available for disk swap.

    • total

      The total amount of memory available to the Erlang emulator, allocated and free. May or may not be equal to the amount of memory configured in the system.

pub type MemoryData {
  MemoryData(total: Int, allocated: Int, worst: #(Pid, Int))
}

Constructors

  • MemoryData(total: Int, allocated: Int, worst: #(Pid, Int))

Functions

pub fn get_check_interval() -> Int

Returns the time interval for the periodic memory check in minutes.

pub external fn get_helper_timeout() -> Int

Returns the timeout value, in seconds, for memory checks.

pub fn get_memory_data() -> MemoryData

Returns the result of the latest memory check, where Total is the total memory size and Allocated the allocated memory size, in bytes.

Worst is the pid and number of allocated bytes of the largest Erlang process on the node. If memsup should not collect process data, that is if the configuration parameter memsup_system_only was set to true, Worst is undefined.

The function is normally asynchronous in the sense that it does not invoke a memory check, but returns the latest available value. The one exception if is the function is called before a first memory check is finished, in which case it does not return a value until the memory check is finished.

Returns all zeroes or raises an exception if memsup is not available, or if all memory checks so far have timed out.

pub external fn get_os_wordsize() -> Int

Returns the wordsize of the current running operating system. Wordsize = 32 | 64 | unsupported_os

pub external fn get_procmem_high_watermark() -> Int

Returns the threshold, in percent, for process memory allocation.

pub external fn get_sysmem_high_watermark() -> Int

Returns the threshold, in percent, for system memory allocation.

pub fn get_system_memory_data() -> Memory
pub fn set_check_interval(minutes: Int) -> Result(Int, Errors)
pub fn set_helper_timeout(seconds: Int) -> Result(Int, Errors)

Changes the timeout value, given in seconds, for memory checks.

The change will take effect for the next memory check and is non-persistent. That is, in the case of a process restart, this value is forgotten and the default value will be used.

pub fn set_procmem_high_watermark(percent: Int) -> Result(
  Int,
  Errors,
)

Changes the threshold for process memory allocation.

The change will take effect during the next periodic memory check and is non-persistent. That is, in case of a process restart, this value is forgotten and the default value will be used.

pub fn set_sysmem_high_watermark(percent: Int) -> Result(
  Int,
  Errors,
)

Changes the threshold, in percent, for system memory allocation.

The change will take effect during the next periodic memory check and is non-persistent. That is, in case of a process restart, this value is forgotten and the default value will be used.

Search Document