Skip to content

Commit

Permalink
Merge e8ede7a into 1fb0905
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkna committed Apr 8, 2021
2 parents 1fb0905 + e8ede7a commit a68257f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions heim-memory/src/sys/windows/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::cmp;
/// https://docs.microsoft.com/en-US/windows/desktop/api/sysinfoapi/ns-sysinfoapi-_memorystatusex
use std::fmt;
use std::mem;
Expand Down Expand Up @@ -40,15 +41,18 @@ pub struct Swap(sysinfoapi::MEMORYSTATUSEX);

impl Swap {
pub fn total(&self) -> Information {
Information::new::<information::byte>(self.0.ullTotalPageFile)
Information::new::<information::byte>(self.0.ullTotalPageFile - self.0.ullTotalPhys)
}

pub fn used(&self) -> Information {
self.total() - self.free()
}

pub fn free(&self) -> Information {
Information::new::<information::byte>(self.0.ullAvailPageFile)
cmp::min(
Information::new::<information::byte>(self.0.ullAvailPageFile - self.0.ullAvailPhys),
self.total(),
)
}
}

Expand Down

0 comments on commit a68257f

Please sign in to comment.