Skip to main content

DeviceInfo

Trait DeviceInfo 

Source
pub trait DeviceInfo {
    // Required method
    fn total_memory_bytes(&self) -> Option<u64>;

    // Provided methods
    fn resident_memory_bytes(&self) -> Option<u64> { ... }
    fn available_memory_bytes(&self) -> Option<u64> { ... }
    fn process_cpu_time(&self) -> Option<Duration> { ... }
    fn release_free_memory(&self) -> bool { ... }
}
Expand description

Provides device and process information.

Required Methods§

Source

fn total_memory_bytes(&self) -> Option<u64>

Total physical memory in bytes, or None if unknown.

Provided Methods§

Source

fn resident_memory_bytes(&self) -> Option<u64>

Memory this process currently holds resident, or None where the platform will not say.

Source

fn available_memory_bytes(&self) -> Option<u64>

Memory this process may still allocate before the platform stops it.

Not the same as free system memory: a device with gigabytes free may still refuse this process another hundred megabytes, and it is the second number that decides whether the next allocation is the one that gets the application killed.

Source

fn process_cpu_time(&self) -> Option<Duration>

Processor time this process has used, user and system together.

Wall-clock time says how long something took; this says how much of a core it took, which is what a background lane that must not heat the device up is actually rationing.

Source

fn release_free_memory(&self) -> bool

Asks the allocator to return free pages to the system.

Returns whether the platform has such a call. Freeing a large buffer does not necessarily shrink the process — an allocator keeps the pages for the next allocation — and on a platform that kills by resident size that is the difference between finishing and being killed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§