pub trait SoftwareMetrics {
// Provided methods
fn thread_metrics(&self, emit: &mut dyn FnMut(&ThreadMetrics<'_>)) { ... }
fn current_heap_free(&self) -> Option<u64> { ... }
fn current_heap_used(&self) -> Option<u64> { ... }
fn current_heap_high_watermark(&self) -> Option<u64> { ... }
fn reset_watermarks(&self) { ... }
}Expand description
What the device’s runtime knows about its own memory.
Every method returns Option and defaults to None, because §11.13.6 marks every
attribute optional and a node without a heap has nothing to say about one. Reporting zero
instead would be a device that looks permanently out of memory.
Provided Methods§
Sourcefn thread_metrics(&self, emit: &mut dyn FnMut(&ThreadMetrics<'_>))
fn thread_metrics(&self, emit: &mut dyn FnMut(&ThreadMetrics<'_>))
Each active software thread in turn (§11.13.6.1).
Sourcefn current_heap_free(&self) -> Option<u64>
fn current_heap_free(&self) -> Option<u64>
Heap bytes free for allocation. “The effective amount MAY be smaller due to heap fragmentation or other reasons” — so this is an upper bound, not a promise.
Sourcefn current_heap_used(&self) -> Option<u64>
fn current_heap_used(&self) -> Option<u64>
Heap bytes currently in use.
Sourcefn current_heap_high_watermark(&self) -> Option<u64>
fn current_heap_high_watermark(&self) -> Option<u64>
The most heap that has ever been in use (§11.13.6.4). “This value SHALL only be reset upon a Node reboot or upon receiving of the ResetWatermarks command.”
Sourcefn reset_watermarks(&self)
fn reset_watermarks(&self)
§11.13.7.1’s ResetWatermarks.
The specification is exact about what “reset” means, and it is not zero: “the server
SHALL set the value of the CurrentHeapHighWatermark attribute to the value of the
CurrentHeapUsed attribute”, and each thread’s StackFreeMinimum to its
StackFreeCurrent. A watermark reset to zero would claim the node had once used no
memory at all, and would then never rise again until usage exceeded the real peak.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".