system_info/unix/posix/
mem.rs1pub use crate::data::mem::SystemMemory;
4
5impl SystemMemory {
6 pub fn new() -> Self {
8 let (total_count, avail_count, size) = unsafe {
9 let total_count = libc::sysconf(libc::_SC_PHYS_PAGES);
10 let avail_count = libc::sysconf(libc::_SC_AVPHYS_PAGES);
11 let size = libc::sysconf(libc::_SC_PAGE_SIZE);
12 if total_count == -1 || avail_count == -1 || size == -1 {
13 return Self {
14 total: 0,
15 avail: 0,
16 }
17 }
18
19 (total_count as u64, avail_count as u64, size as u64)
20 };
21
22 Self {
23 total: total_count.saturating_mul(size),
24 avail: avail_count.saturating_mul(size),
25 }
26 }
27}