Skip to content

runtime #

Description

runtime provides access to functions describing the current platform:

  • whether it is 32bit or 64bit
  • how many CPUs/cores are available
  • total/free physical memory
  • whether the platform is little endian or big endian
  • etc.

On FreeBSD, used_memory() reads current resident memory through kern.proc.rlimit_usage. It does not require libprocstat. It reports peak resident memory through getrusage on kernels without that interface and when compiled with TinyCC.

fn free_memory #

fn free_memory() !uint

free_memory returns free physical memory found on the system.

Note: implementation available only on Darwin, FreeBSD, Linux, OpenBSD and Windows. Otherwise, returns 'free_memory: not implemented'.

fn is_32bit #

fn is_32bit() bool

is_32bit returns true if the current executable is running on a 32 bit system.

fn is_64bit #

fn is_64bit() bool

is_64bit returns true if the current executable is running on a 64 bit system.

fn is_big_endian #

fn is_big_endian() bool

is_big_endian returns true if the current executable is running on a big-endian system.

fn is_little_endian #

fn is_little_endian() bool

is_little_endian returns true if the current executable is running on a little-endian system.

fn nr_cpus #

fn nr_cpus() int

nr_cpus returns the number of virtual CPU cores found on the system.

fn nr_jobs #

fn nr_jobs() int

nr_jobs returns the same as nr_cpus, but influenced by the env variable VJOBS. If the environment variable VJOBS is set, and has a value > 0, then nr_jobs will return that number instead. This is useful for runtime tweaking of e.g. threaded or concurrent code.

fn total_memory #

fn total_memory() !uint

total_memory returns total physical memory found on the system.

fn used_memory #

fn used_memory() !u64

used_memory retrieves the current physical memory usage of the process.

struct C.MEMORYSTATUS #

@[typedef]

Available on Windows only.

struct C.MEMORYSTATUS {
	dwTotalPhys uint
	dwAvailPhys uint
}

struct C.host_t #

@[typedef]

Available on macOS only.

struct C.host_t {}

struct C.task_t #

@[typedef]

Available on macOS only.

struct C.task_t {}

struct C.vm_size_t #

@[typedef]

Available on macOS only.

struct C.vm_size_t {
}

struct C.vm_statistics64_data_t #

@[typedef]

Available on macOS only.

struct C.vm_statistics64_data_t {
	free_count          u32
	purgeable_count     u32
	speculative_count   u32
	external_page_count u32
}