Skip to content

Commit

Permalink
The memory information is returned in bytes and not kb.
Browse files Browse the repository at this point in the history
Fix the documentation of the Information struct, and the example
system_information that uses it.

Co-authored-by: =?UTF-8?q?Ahmet=20Kaan=20G=C3=9CM=C3=9C=C5=9E?= <96421894+Tahinli@users.noreply.github.com>
  • Loading branch information
2 people authored and hecrj committed Feb 2, 2024
1 parent aea1725 commit 790ac77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions examples/system_information/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,25 @@ impl Application for Example {
));

let memory_readable =
ByteSize::kb(information.memory_total).to_string();
ByteSize::b(information.memory_total).to_string();

let memory_total = text(format!(
"Memory (total): {} kb ({memory_readable})",
"Memory (total): {} bytes ({memory_readable})",
information.memory_total,
));

let memory_text = if let Some(memory_used) =
information.memory_used
{
let memory_readable = ByteSize::kb(memory_used).to_string();
let memory_readable = ByteSize::b(memory_used).to_string();

format!("{memory_used} kb ({memory_readable})")
format!("{memory_used} bytes ({memory_readable})")
} else {
String::from("None")
};

let memory_used = text(format!("Memory (used): {memory_text}"));
let memory_used =
text(format!("Memory used by this process: {memory_text}"));

let graphics_adapter = text(format!(
"Graphics adapter: {}",
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/system/information.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ pub struct Information {
pub cpu_brand: String,
/// The number of physical cores on the processor
pub cpu_cores: Option<usize>,
/// Total RAM size, KB
/// Total RAM size, in bytes
pub memory_total: u64,
/// Memory used by this process, KB
/// Memory used by this process, in bytes
pub memory_used: Option<u64>,
/// Underlying graphics backend for rendering
pub graphics_backend: String,
Expand Down

0 comments on commit 790ac77

Please sign in to comment.